From 93dcb13ed9b3c34d939740e7da9948b2b39476e7 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 28 Jan 2005 17:03:57 +0000 Subject: [PATCH] Only show page errors when debugging is on (in case we can recover) --- lib/pagelib.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/pagelib.php b/lib/pagelib.php index 8fcfa1a0c5..1c30ed9349 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -25,6 +25,8 @@ define('MOODLE_PAGE_COURSE', 'course'); */ function page_create_object($type, $id = NULL) { + global $CFG; + $data = new stdClass; $data->pagetype = $type; $data->pageid = $id; @@ -34,9 +36,11 @@ function page_create_object($type, $id = NULL) { $object = &new $classname; // TODO: subclassing check here - if($object->get_type() !== $type) { + if ($object->get_type() !== $type) { // Somehow somewhere someone made a mistake - error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')'); + if ($CFG->debug > 7) { + error('Page object\'s type ('. $object->get_type() .') does not match requested type ('. $type .')'); + } } $object->init_quick($data); @@ -49,23 +53,30 @@ function page_create_object($type, $id = NULL) { */ function page_map_class($type, $classname = NULL) { + global $CFG; + static $mappings = NULL; - if($mappings === NULL) { + if ($mappings === NULL) { $mappings = array( MOODLE_PAGE_COURSE => 'page_course' ); } - if(!empty($type) && !empty($classname)) { + if (!empty($type) && !empty($classname)) { $mappings[$type] = $classname; } - if(!isset($mappings[$type])) { - error('Page class mapping requested for unknown type: '.$type); + + if (!isset($mappings[$type])) { + if ($CFG->debug > 7) { + error('Page class mapping requested for unknown type: '.$type); + } } - if(!class_exists($mappings[$type])) { - error('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined'); + if (!class_exists($mappings[$type])) { + if ($CFG->debug > 7) { + error('Page class mapping for id "'.$type.'" exists but class "'.$mappings[$type].'" is not defined'); + } } return $mappings[$type]; @@ -485,4 +496,4 @@ class page_course extends page_base { } } -?> \ No newline at end of file +?> -- 2.39.5