blocks/admin_tree: exit early for non-admins

Saves >10DBq and 18 includes at the homepage for all nonadmin users.
For non admin users, this makes the homepage _much_ more lightweight.

  Before: inc 101  DBq 51 time 1.2s
  After:  inc  76  DBq 36 time 0.2s

So this commit shaves 1 full second for the non-logged-in homepage.

Still pretty bad on the includes, but shaved a good 25 files and 15 DBqs.
This commit is contained in:
martinlanghoff
2007-09-19 07:22:24 +00:00
parent d4c4ecb808
commit 84a34f6ed3
+7 -2
View File
@@ -100,13 +100,18 @@ class block_admin_tree extends block_base {
global $CFG, $ADMIN;
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
$this->content = '';
return '';
}
if ($this->content !== NULL) {
return $this->content;
}
require_once($CFG->libdir.'/adminlib.php');
$adminroot = admin_get_root();
if ($this->pathtosection = $adminroot->path($this->section)) {
$this->pathtosection = array_reverse($this->pathtosection);
array_pop($this->pathtosection);