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.
This commit is contained in:
defacer
2005-02-28 04:16:41 +00:00
parent 3f6aba0c42
commit b5e9682173
+10 -1
View File
@@ -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;
}