]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Rewriting core debug messages to be more informative.
authornickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 16 Oct 2009 22:53:22 +0000 (22:53 +0000)
committernickw <nickw@36083f99-b078-4883-b0ff-0f9b5a30f544>
Fri, 16 Oct 2009 22:53:22 +0000 (22:53 +0000)
Introducing the concept of levels for Elgg debugging: notices, warnings and errors are displayed when the appropriate debugging level is enabled. An additional level of "debug" exists to differentiate from errors.

git-svn-id: http://code.elgg.org/elgg/trunk@3560 36083f99-b078-4883-b0ff-0f9b5a30f544

18 files changed:
engine/lib/api.php
engine/lib/database.php
engine/lib/elgglib.php
engine/lib/entities.php
engine/lib/group.php
engine/lib/languages.php
engine/lib/memcache.php
engine/lib/metastrings.php
engine/lib/notification.php
engine/lib/objects.php
engine/lib/sites.php
engine/lib/users.php
engine/start.php
engine/tests/suite.php
views/default/messages/exceptions/exception.php
views/failsafe/messages/exceptions/exception.php
views/opendd/messages/exceptions/exception.php
views/xml/messages/exceptions/exception.php

index 53af1af67d2cb6fe9367ae6cd196de296e7da02d..3019226365458c25249683519c71588ae6647b09 100644 (file)
@@ -104,7 +104,7 @@ abstract class GenericResult {
                        $result->result = $resultdata;
                }
 
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug == true)) {
+               if (isset($CONFIG->debug)) {
                        if (count($ERRORS)) {
                                $result->runtime_errors = $ERRORS;
                        }
@@ -656,9 +656,7 @@ function map_api_hash($algo) {
 function calculate_hmac($algo, $time, $api_key, $secret_key, $get_variables, $post_hash = "") {
        global $CONFIG;
 
-       if ((isset($CONFIG)) && ($CONFIG->debug)) {
-               error_log("HMAC Parts: $algo, $time, $api_key, $secret_key, $get_variables, $post_hash");
-       }
+       elgg_log("HMAC Parts: $algo, $time, $api_key, $secret_key, $get_variables, $post_hash");
 
        $ctx = hash_init(map_api_hash($algo), HASH_HMAC, $secret_key);
 
@@ -1115,9 +1113,7 @@ function send_api_call(array $keys, $url, array $call, $method = 'GET', $post_da
        $context = stream_context_create($opts);
 
        // Send the query and get the result and decode.
-       if ((isset($CONFIG->debug)) && ($CONFIG->debug)) {
-               error_log("APICALL: $url");
-       }
+       elgg_log("APICALL: $url");
        $APICLIENT_LAST_CALL_RAW = file_get_contents($url, false, $context);
 
        $APICLIENT_LAST_CALL = unserialize($APICLIENT_LAST_CALL_RAW);
index 0faa6f029a66a13e3bac44d1d61d3685e2902c4a..96dac3846f60f705f02a78e458b630bfd8ff6db1 100644 (file)
@@ -11,7 +11,6 @@
  * @link http://elgg.org/
  */
 
-$DB_PROFILE = array();
 $DB_QUERY_CACHE = array();
 $DB_DELAYED_QUERIES = array();
 
@@ -51,7 +50,7 @@ function establish_db_link($dblinkname = "readwrite") {
        // Connect to database
        if (!$dblink[$dblinkname] = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, true)) {
                $msg = sprintf(elgg_echo('DatabaseException:WrongCredentials'),
-                               $CONFIG->dbuser, $CONFIG->dbhost, $CONFIG->debug ? $CONFIG->dbpass : "****");
+                               $CONFIG->dbuser, $CONFIG->dbhost, "****");
                throw new DatabaseException($msg);
        }
        if (!mysql_select_db($CONFIG->dbname, $dblink[$dblinkname])) {
@@ -92,20 +91,9 @@ function setup_db_connections() {
  * Shutdown hook to display profiling information about db (debug mode)
  */
 function db_profiling_shutdown_hook() {
-       global $CONFIG, $DB_PROFILE, $dbcalls;
-
-       if (isset($CONFIG->debug) && $CONFIG->debug) {
-               error_log("***************** DB PROFILING ********************");
-
-               $DB_PROFILE = array_count_values($DB_PROFILE);
-
-               foreach ($DB_PROFILE as $k => $v) {
-                       error_log("$v times: '$k' ");
-               }
-
-               error_log("DB Queries for this page: $dbcalls");
-               error_log("***************************************************");
-       }
+       global $dbcalls;
+       
+       elgg_log("DB Queries for this page: $dbcalls", 'DEBUG');
 }
 
 /**
@@ -123,7 +111,7 @@ function db_delayedexecution_shutdown_hook() {
                                $query_details['h']($result);
                        }
                } catch (Exception $e) { // Suppress all errors since these can't be delt with here
-                       if (isset($CONFIG->debug) && $CONFIG->debug) {
+                       if (isset($CONFIG->debug)) {
                                error_log($e);
                        }
                }
@@ -183,13 +171,10 @@ function explain_query($query, $link) {
  * @return Returns a the result of mysql_query
  */
 function execute_query($query, $dblink) {
-       global $CONFIG, $dbcalls, $DB_PROFILE, $DB_QUERY_CACHE;
+       global $CONFIG, $dbcalls, $DB_QUERY_CACHE;
 
        $dbcalls++;
 
-       //if ((isset($CONFIG->debug)) && ($CONFIG->debug==true))
-                       $DB_PROFILE[] = $query;
-
        $result = mysql_query($query, $dblink);
        if ($DB_QUERY_CACHE) {
                $DB_QUERY_CACHE[$query] = -1; // Set initial cache to -1
@@ -265,9 +250,7 @@ function get_data($query, $callback = "") {
        }
 
        if ((isset($cached_query)) && ($cached_query)) {
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-                       error_log ("$query results returned from cache");
-               }
+               elgg_log("$query results returned from cache");
 
                if ($cached_query === -1) {
                        // Last time this query returned nothing, so return an empty array
@@ -292,19 +275,14 @@ function get_data($query, $callback = "") {
        }
 
        if (empty($resultarray)) {
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-                       error_log("WARNING: DB query \"$query\" returned no results.");
-                       return false;
-               }
-       }
-
-       if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-               error_log("$query results cached");
+               elgg_log("DB query \"$query\" returned no results.");
+               return false;
        }
 
        // Cache result
        if ($DB_QUERY_CACHE) {
                $DB_QUERY_CACHE[$query] = $resultarray;
+               elgg_log("$query results cached");
        }
 
        return $resultarray;
@@ -325,9 +303,7 @@ function get_data_row($query, $callback = "") {
        }
 
        if ((isset($cached_query)) && ($cached_query)) {
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-                       error_log ("$query results returned from cache");
-               }
+               elgg_log("$query results returned from cache");
 
                if ($cached_query === -1) {
                        // Last time this query returned nothing, so return false
@@ -344,12 +320,9 @@ function get_data_row($query, $callback = "") {
                $row = mysql_fetch_object($result);
 
                // Cache result (even if query returned no data)
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-                       error_log("$query results cached");
-               }
-
                if ($DB_QUERY_CACHE) {
                        $DB_QUERY_CACHE[$query] = $row;
+                       elgg_log("$query results cached");
                }
 
                if (!empty($callback) && is_callable($callback)) {
@@ -361,11 +334,8 @@ function get_data_row($query, $callback = "") {
                }
        }
 
-       if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-               error_log("WARNING: DB query \"$query\" returned no results.");
-       }
-
-       return false;
+       elgg_log("$query returned no results.");
+       return FALSE;
 }
 
 /**
@@ -384,9 +354,7 @@ function insert_data($query) {
                $DB_QUERY_CACHE->clear();
        }
 
-       if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-               error_log("Query cache invalidated");
-       }
+       elgg_log("Query cache invalidated");
 
        if (execute_query("$query", $dblink)) {
                return mysql_insert_id($dblink);
@@ -409,10 +377,7 @@ function update_data($query) {
        // Invalidate query cache
        if ($DB_QUERY_CACHE) {
                $DB_QUERY_CACHE->clear();
-       }
-
-       if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-               error_log("Query cache invalidated");
+               elgg_log("Query cache invalidated");
        }
 
        if (execute_query("$query", $dblink)) {
@@ -438,10 +403,7 @@ function delete_data($query) {
        // Invalidate query cache
        if ($DB_QUERY_CACHE) {
                $DB_QUERY_CACHE->clear();
-       }
-
-       if ((isset($CONFIG->debug)) && ($CONFIG->debug==true)) {
-               error_log("Query cache invalidated");
+               elgg_log("Query cache invalidated");
        }
 
        if (execute_query("$query", $dblink)) {
index f0a0b25823a7dc4a9c609195e4eb1319fe853a62..36e87eca9d65c05b093ebf65d9078cd6c89c5c3a 100644 (file)
@@ -256,22 +256,20 @@ function elgg_view($view, $vars = "", $bypass = false, $debug = false, $viewtype
        foreach($viewlist as $priority => $view) {
                $view_location = elgg_get_view_location($view, $viewtype);
 
-               if (file_exists($view_location . "{$viewtype}/{$view}.php")
-                       && !include($view_location . "{$viewtype}/{$view}.php")) {
+               if (file_exists("$view_location$viewtype/$view.php")
+                       && !include("$view_location$viewtype/$view.php")) {
                        $success = false;
 
                        if ($viewtype != "default") {
-                               if (include($view_location . "default/{$view}.php")) {
+                               if (include("{$view_location}default/$view.php")) {
                                        $success = true;
                                }
                        }
-                       if (!$success && isset($CONFIG->debug) && $CONFIG->debug == true) {
-                               error_log(" [This view ({$view}) does not exist] ");
+                       if (!$success) {
+                               elgg_log(" [This view ($view) does not exist] ", 'ERROR');
                        }
-               } else if (isset($CONFIG->debug) && $CONFIG->debug == true
-                       && !file_exists($view_location . "{$viewtype}/{$view}.php")) {
-                       error_log($view_location . "{$viewtype}/{$view}.php");
-                       error_log(" [This view ({$view}) does not exist] ");
+               } else if (!file_exists("$view_location$viewtype/$view.php")) {
+                       elgg_log(" [This view ($view) does not exist] ", 'WARNING');
                }
 
        }
@@ -1711,12 +1709,12 @@ function trigger_plugin_hook($hook, $entity_type, $params = null, $returnvalue =
  * @param array $vars An array that points to the active symbol table at the point that the error occurred
  */
 function __elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
-       $error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file " . $filename . " (line " . $linenum . ")";
+       $error = date("Y-m-d H:i:s (T)") . ": \"$errmsg\" in file $filename (line $linenum)";
 
        switch ($errno) {
                case E_USER_ERROR:
-                       error_log("ERROR: " . $error);
-                       register_error("ERROR: " . $error);
+                       error_log("ERROR: $error");
+                       register_error("ERROR: $error");
 
                        // Since this is a fatal error, we want to stop any further execution but do so gracefully.
                        throw new Exception($error);
@@ -1724,21 +1722,77 @@ function __elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
 
                case E_WARNING :
                case E_USER_WARNING :
-                       error_log("WARNING: " . $error);
-                       // register_error("WARNING: " . $error);
+                       error_log("WARNING: $error");
                        break;
 
                default:
                        global $CONFIG;
                        if (isset($CONFIG->debug)) {
-                               error_log("DEBUG: " . $error);
+                               error_log("NOTICE: $error");
                        }
-                       // register_error("DEBUG: " . $error);
        }
 
        return true;
 }
 
+/**
+ * Throws a message to the Elgg logger
+ *
+ * The Elgg log is currently implemented such that any messages sent at a level
+ * greater than or equal to the debug setting will be dumped to the screen.
+ *
+ * Note: No messages will be displayed unless debugging has been enabled.
+ *
+ * @param str $message User message
+ * @param str $level NOTICE | WARNING | ERROR | DEBUG
+ * @return bool
+ */
+function elgg_log($message, $level='NOTICE') {
+       global $CONFIG;
+       
+       // only log when debugging is enabled
+       if (isset($CONFIG->debug)) {
+               switch ($level) {
+                       case 'DEBUG':
+                       case 'ERROR':
+                               // always report
+                               elgg_dump("$level: $message");
+                               break;
+                       case 'WARNING':
+                               // report execept if user wants only errors
+                               if ($config->debug != 'ERROR') {
+                                       elgg_dump("$level: $message");
+                               }
+                               break;
+                       case 'NOTICE':
+                       default:
+                               // only report when lowest level is desired
+                               if ($config->debug == 'NOTICE') {
+                                       elgg_dump("$level: $message");
+                               }
+                               break;
+               }
+               
+               return TRUE;
+       }
+       
+       return FALSE;
+}
+
+/**
+ * Extremely generic var_dump-esque wrapper
+ *
+ * Immediately dumps the given $value to the screen as a human-readable string.
+ *
+ * @param mixed $value
+ * @return void
+ */
+function elgg_dump($value) {
+       echo '<pre>';
+       print_r($value);
+       echo '</pre>';
+}
+
 /**
  * Custom exception handler.
  * This function catches any thrown exceptions and handles them appropriately.
@@ -2015,7 +2069,7 @@ function callpath_gatekeeper($path, $include_subdirs = true, $strict_mode = fals
                return false;
        }
 
-       if ($CONFIG->debug) {
+       if (isset($CONFIG->debug)) {
                system_message("Gatekeeper'd function called from {$callstack[1]['file']}:{$callstack[1]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
        }
 
@@ -2263,13 +2317,12 @@ function js_page_handler($page) {
  *
  */
 function __elgg_shutdown_hook() {
-       global $CONFIG, $START_MICROTIME;
+       global $START_MICROTIME;
 
        trigger_elgg_event('shutdown', 'system');
-
-       if ($CONFIG->debug) {
-               error_log("Page {$_SERVER['REQUEST_URI']} generated in ".(float)(microtime(true)-$START_MICROTIME)." seconds");
-       }
+       
+       $time = (float)(microtime(TRUE) - $START_MICROTIME);
+       elgg_log("Page {$_SERVER['REQUEST_URI']} generated in $time seconds", 'DEBUG');
 }
 
 /**
index 211fbc05cc56bc6f3dbbbffaa0176d8800ac59b2..373654431d42d60972262028c515dd36eadabd44 100644 (file)
@@ -1479,27 +1479,9 @@ function get_entity_as_row($guid) {
        }
 
        $guid = (int) $guid;
-
-       /*$row = retrieve_cached_entity_row($guid);
-       if ($row)
-       {
-               // We have already cached this object, so retrieve its value from the cache
-               if (isset($CONFIG->debug) && $CONFIG->debug)
-                       error_log("** Retrieving GUID:$guid from cache");
-
-               return $row;
-       }
-       else
-       {*/
-               // Object not cached, load it.
-               if (isset($CONFIG->debug) && $CONFIG->debug == true) {
-                       error_log("** GUID:$guid loaded from DB");
-               }
-
-               $access = get_access_sql_suffix();
-
-               return get_data_row("SELECT * from {$CONFIG->dbprefix}entities where guid=$guid and $access");
-       //}
+       $access = get_access_sql_suffix();
+       
+       return get_data_row("SELECT * from {$CONFIG->dbprefix}entities where guid=$guid and $access");
 }
 
 /**
index 664837a27e09f9ee57d1e829b4099cecffbfee18..9fc937ff3dace4e3405637d82b5172ff32f2a5bd 100644 (file)
@@ -318,24 +318,7 @@ function get_group_entity_as_row($guid) {
 
        $guid = (int)$guid;
 
-       /*$row = retrieve_cached_entity_row($guid);
-       if ($row)
-       {
-               // We have already cached this object, so retrieve its value from the cache
-               if (isset($CONFIG->debug) && $CONFIG->debug)
-                       error_log("** Retrieving sub part of GUID:$guid from cache");
-
-               return $row;
-       }
-       else
-       {*/
-       // Object not cached, load it.
-       if (isset($CONFIG->debug) && $CONFIG->debug == true) {
-               error_log("** Sub part of GUID:$guid loaded from DB");
-       }
-
        return get_data_row("SELECT * from {$CONFIG->dbprefix}groups_entity where guid=$guid");
-       //}
 }
 
 /**
index 19f3c138aa01d28dee5e13442ba33c78c604af92..898fc725fe4b2109bfdc27822c158f350ffb860b 100644 (file)
@@ -125,10 +125,7 @@ function register_translations($path, $load_all = false) {
 
        // Get the current language based on site defaults and user preference
        $current_language = get_current_language();
-
-       if (isset($CONFIG->debug) && $CONFIG->debug == true) {
-               error_log("Translations loaded from : $path");
-       }
+       elgg_log("Translations loaded from: $path");
 
        if ($handle = opendir($path)) {
                while ($language = readdir($handle)) {
@@ -140,7 +137,7 @@ function register_translations($path, $load_all = false) {
                        }
                }
        } else {
-               error_log("Missing translation path $path");
+               elgg_log("Missing translation path $path", 'ERROR');
        }
 }
 
index 498d1ff4fee587cc1e35ab697fdee29c729f23ca..ed93cacf032574206c6051e3c3fb1aff13eaa7ce 100644 (file)
@@ -77,9 +77,7 @@ class ElggMemcache extends ElggSharedMemoryCache {
                                }
                        }
                } else {
-                       if ((isset($CONFIG->debug)) && ($CONFIG->debug == true)) {
-                               error_log(elgg_echo('memcache:noaddserver'));
-                       }
+                       elgg_log(elgg_echo('memcache:noaddserver'), 'ERROR');
 
                        $server = $CONFIG->memcache_servers[0];
                        if (is_array($server)) {
@@ -131,8 +129,8 @@ class ElggMemcache extends ElggSharedMemoryCache {
                $key = $this->make_memcache_key($key);
 
                $result = $this->memcache->set($key, $data, null, $this->expires);
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug == true) && (!$result)) {
-                       error_log("MEMCACHE: FAILED TO SAVE $key");
+               if (!$result) {
+                       elgg_log("MEMCACHE: FAILED TO SAVE $key", 'ERROR');
                }
 
                return $result;
@@ -142,8 +140,8 @@ class ElggMemcache extends ElggSharedMemoryCache {
                $key = $this->make_memcache_key($key);
 
                $result = $this->memcache->get($key);
-               if ((isset($CONFIG->debug)) && ($CONFIG->debug == true) && (!$result)) {
-                       error_log("MEMCACHE: FAILED TO LOAD $key");
+               if (!$result) {
+                       elgg_log("MEMCACHE: FAILED TO LOAD $key", 'ERROR');
                }
 
                return $result;
index 519d186e4782b853abd0069d3fb1ba8baed4998a..3e8796d3ff016b5398deb7f3fadabdf3baecd0b1 100644 (file)
@@ -28,10 +28,7 @@ function get_metastring_id($string, $case_sensitive = true) {
        $string = sanitise_string($string);
        $result = array_search($string, $METASTRINGS_CACHE);
        if ($result!==false) {
-               if (isset($CONFIG->debug) && $CONFIG->debug) {
-                       error_log("** Returning id for string:$string from cache.");
-               }
-
+               elgg_log("** Returning id for string:$string from cache.");
                return $result;
        }
 
@@ -68,9 +65,7 @@ function get_metastring_id($string, $case_sensitive = true) {
                        $metastrings_memcache->save($row->string, $row->id);
                }
 
-               if (isset($CONFIG->debug) && $CONFIG->debug) {
-                       error_log("** Cacheing string '{$row->string}'");
-               }
+               elgg_log("** Cacheing string '{$row->string}'");
 
                return $row->id;
        } else {
@@ -92,9 +87,7 @@ function get_metastring($id) {
        $id = (int) $id;
 
        if (isset($METASTRINGS_CACHE[$id])) {
-               if ($CONFIG->debug) {
-                       error_log("** Returning string for id:$id from cache.");
-               }
+               elgg_log("** Returning string for id:$id from cache.");
 
                return $METASTRINGS_CACHE[$id];
        }
@@ -102,10 +95,7 @@ function get_metastring($id) {
        $row = get_data_row("SELECT * from {$CONFIG->dbprefix}metastrings where id='$id' limit 1");
        if ($row) {
                $METASTRINGS_CACHE[$id] = $row->string; // Cache it
-
-               if ($CONFIG->debug) {
-                       error_log("** Cacheing string '{$row->string}'");
-               }
+               elgg_log("** Cacheing string '{$row->string}'");
 
                return $row->string;
        }
index 6284e874d753ce438d6f60ae63b07a065ba609e5..ad65455f3a5a12a25cf3eab8257699e37d9fba51 100644 (file)
@@ -109,9 +109,7 @@ function notify_user($to, $from, $subject, $message, array $params = NULL, $meth
                                                error_log(sprintf(elgg_echo('NotificationException:NoHandlerFound'), $method));
                                        }
 
-                                       if ($CONFIG->debug) {
-                                               error_log("Sending message to $guid using $method");
-                                       }
+                                       elgg_log("Sending message to $guid using $method");
 
                                        // Trigger handler and retrieve result.
                                        try {
index a81925ce169d55f095c6380593275c6a43e36b9a..7e21550aae7838096588e5096be7972878123e23 100644 (file)
@@ -215,25 +215,7 @@ function get_object_entity_as_row($guid) {
        global $CONFIG;
 
        $guid = (int)$guid;
-
-       /*$row = retrieve_cached_entity_row($guid);
-       if ($row)
-       {
-               // We have already cached this object, so retrieve its value from the cache
-               if (isset($CONFIG->debug) && $CONFIG->debug)
-                       error_log("** Retrieving sub part of GUID:$guid from cache");
-
-               return $row;
-       }
-       else
-       {*/
-               // Object not cached, load it.
-               if ($CONFIG->debug) {
-                       error_log("** Sub part of GUID:$guid loaded from DB");
-               }
-
-               return get_data_row("SELECT * from {$CONFIG->dbprefix}objects_entity where guid=$guid");
-       //}
+       return get_data_row("SELECT * from {$CONFIG->dbprefix}objects_entity where guid=$guid");
 }
 
 /**
index 7a1375d46f7ad8ab1539ddbcc06e6cf711e190a7..d38113d2741288c358fb4e69079bbc2e80e07e1a 100644 (file)
@@ -252,25 +252,7 @@ function get_site_entity_as_row($guid) {
        global $CONFIG;
 
        $guid = (int)$guid;
-
-       /*$row = retrieve_cached_entity_row($guid);
-       if ($row)
-       {
-               // We have already cached this object, so retrieve its value from the cache
-               if (isset($CONFIG->debug) && $CONFIG->debug)
-                       error_log("** Retrieving sub part of GUID:$guid from cache");
-
-               return $row;
-       }
-       else
-       {*/
-       // Object not cached, load it.
-       if (isset($CONFIG->debug) && $CONFIG->debug == true) {
-               error_log("** Sub part of GUID:$guid loaded from DB");
-       }
-
        return get_data_row("SELECT * from {$CONFIG->dbprefix}sites_entity where guid=$guid");
-       //}
 }
 
 /**
index 7d1fa3d586788e175b901127052c57f934f81d72..29a2dd42fd64832dfa7a3612c70d35ad893a7866 100644 (file)
@@ -372,26 +372,8 @@ class ElggUser extends ElggEntity
 function get_user_entity_as_row($guid) {
        global $CONFIG;
 
-       /*$row = retrieve_cached_entity_row($guid);
-       if ($row)
-       {
-               // We have already cached this object, so retrieve its value from the cache
-               if (isset($CONFIG->debug) && $CONFIG->debug == true)
-                       error_log("** Retrieving sub part of GUID:$guid from cache");
-
-               return $row;
-       }
-       else
-       {*/
-       // Object not cached, load it.
-       if (isset($CONFIG->debug) && $CONFIG->debug == true) {
-               error_log("** Sub part of GUID:$guid loaded from DB");
-       }
-
        $guid = (int)$guid;
-
        return get_data_row("SELECT * from {$CONFIG->dbprefix}users_entity where guid=$guid");
-       //}
 }
 
 /**
index b6699309bd7ae54c793d6ba19fa11ecfb3e02ee2..7caa35b0f3e7a250590741269693dc01d554e664 100644 (file)
@@ -133,9 +133,7 @@ if ($sanitised = sanitised()) {
 
        // Include them
        foreach($files as $file) {
-               if (isset($CONFIG->debug) && $CONFIG->debug) {
-                       error_log("Loading $file...");
-               }
+               elgg_log("Loading $file...");
                if (!include_once($file)) {
                        throw new InstallationException("Could not load {$file}");
                }
index 01056a218aed18fafa369c5f1d37f45786e184d5..c3de185ffcf2eb34a720f519cee58b5fdeddc8d3 100755 (executable)
@@ -28,19 +28,19 @@ foreach ($test_files as $file) {
 }
 
 // Only run tests in debug mode.
-if ($CONFIG->debug > 0) {
-       if (TextReporter::inCli()) {
-               // In CLI error codes are returned.
-               // 0 is success.
-               elgg_set_ignore_access(TRUE);
-               exit ($suite->Run(new TextReporter()) ? 0 : 1 );
-       }
-       // Ensure that only logged-in users can see this page
-       //admin_gatekeeper();
-       $old = elgg_set_ignore_access(TRUE);
-       $suite->Run(new HtmlReporter());
-       elgg_set_ignore_access($old);
-} else {
+if (!isset($CONFIG->debug)) {
        // @todo display an error?
        exit (1);
 }
+
+if (TextReporter::inCli()) {
+       // In CLI error codes are returned: 0 is success
+       elgg_set_ignore_access(TRUE);
+       exit ($suite->Run(new TextReporter()) ? 0 : 1 );
+}
+
+// Ensure that only logged-in users can see this page
+//admin_gatekeeper();
+$old = elgg_set_ignore_access(TRUE);
+$suite->Run(new HtmlReporter());
+elgg_set_ignore_access($old);
index c93883cbc6e4316ce9e745aa4b0ecca689fea8b3..65ec7cdbf9c98d8866323b67ee01d533b63cfa79 100644 (file)
@@ -24,7 +24,7 @@ $body = <<< END
 </p>
 END;
 
-if ($CONFIG->debug) {
+if (isset($CONFIG->debug)) {
        $details = elgg_view('output/longtext', array('value' => htmlentities(print_r($vars['object'], true), ENT_QUOTES, 'UTF-8')));
        $body .= <<< END
        <hr />
index f6fb4d144ba1b5916b04f257396ab4eee27e5915..d3877f0c86b0991dc8944f6ac276af57b8300778 100644 (file)
@@ -24,7 +24,7 @@ global $CONFIG;
        </span>
 </p>
 
-<?php if ($CONFIG->debug) { ?>
+<?php if (isset($CONFIG->debug)) { ?>
 
 <p class="messages-exception-detail" style="background:#FDFFC3;display:block;padding:10px;">
        <?php
index c020c0e04ddfa21bee222f9eecb78904bcac319d..0c932f4e506043e354dcc3c4f182e1e926391b8d 100644 (file)
@@ -15,7 +15,7 @@ global $CONFIG;
 ?>
 <!--
 <?php echo get_class($vars['object']); ?>: <?php echo autop($vars['object']->getMessage()); ?>
-<?php if ($CONFIG->debug) { ?>
+<?php if (isset($CONFIG->debug)) { ?>
 <?php
        echo print_r($vars['object'], true);
 ?>
index f13457e7ce30ecf2e0f32f339405cfd20fb78105..cc899ac18b3eab785fcee1cd14123bded5476bfc 100644 (file)
@@ -17,7 +17,7 @@ global $CONFIG;
 <?php echo get_class($vars['object']); ?>: <?php echo autop($vars['object']->getMessage()); ?>
 
 
-<?php if ($CONFIG->debug) { ?>
+<?php if (isset($CONFIG->debug)) { ?>
 <?php
 
                echo print_r($vars['object'], true);