From e6262fcd0dbbe22138c2a9bbbc3ed8d4ba3f8034 Mon Sep 17 00:00:00 2001 From: poltawski Date: Sun, 28 Oct 2007 23:06:39 +0000 Subject: [PATCH] MDL-11937 - save 100 database queries in the case of the admin bookmarks block without bookmarks on non-admin page Merged from MOODLE_19_STABLE --- blocks/admin_bookmarks/block_admin_bookmarks.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/blocks/admin_bookmarks/block_admin_bookmarks.php b/blocks/admin_bookmarks/block_admin_bookmarks.php index 9d709ea3c58..2b4fd5db531 100644 --- a/blocks/admin_bookmarks/block_admin_bookmarks.php +++ b/blocks/admin_bookmarks/block_admin_bookmarks.php @@ -31,9 +31,6 @@ class block_admin_bookmarks extends block_base { global $CFG, $USER, $PAGE; - require_once($CFG->libdir.'/adminlib.php'); - $adminroot = admin_get_root(); - if ($this->content !== NULL) { return $this->content; } @@ -41,6 +38,10 @@ class block_admin_bookmarks extends block_base { $this->content = new stdClass; $this->content->text = ''; if (get_user_preferences('admin_bookmarks')) { + // this is expensive! Only require when bookmakrs exist.. + require_once($CFG->libdir.'/adminlib.php'); + $adminroot = admin_get_root(); + $bookmarks = explode(',',get_user_preferences('admin_bookmarks')); // hmm... just a liiitle (potentially) processor-intensive // (recall that $adminroot->locate is a huge recursive call... and we're calling it repeatedly here