From b5e9682173e600cd6e6e08f04df50b7639ba300a Mon Sep 17 00:00:00 2001 From: defacer Date: Mon, 28 Feb 2005 04:16:41 +0000 Subject: [PATCH] Adding caching to page_import_types. Actually the caching is REQUIRED for the function to work, because otherwise it would barf on duplicate class declaration the second time it was called with the same arguments. --- lib/pagelib.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pagelib.php b/lib/pagelib.php index c0cf861fb52..a4eb0b562cd 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -21,7 +21,15 @@ if(record_exists('block_instance', 'pagetype', 'course')) { function page_import_types($path) { global $CFG; + + static $types = array(); + $path = clean_param($path, PARAM_PATH); + + if(isset($types[$path])) { + return $types[$path]; + } + $file = $CFG->dirroot.'/'.$path.'pagelib.php'; if(is_file($file)) { @@ -29,8 +37,9 @@ function page_import_types($path) { if(!isset($DEFINEDPAGES)) { error('Imported '.$file.' but found no page classes'); } - return $DEFINEDPAGES; + return $types[$path] = $DEFINEDPAGES; } + return false; }