]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Fixes #4278 deprecation notices ignore debug level but do respect whether the admin...
authorCash Costello <cash.costello@gmail.com>
Sun, 8 Jan 2012 14:25:43 +0000 (09:25 -0500)
committerCash Costello <cash.costello@gmail.com>
Sun, 8 Jan 2012 14:25:43 +0000 (09:25 -0500)
engine/lib/elgglib.php

index 6f9fb0ded68e0731b83729cd485d22395a013bdd..b044d230f4c702fcd7f01c14b66ff3f014a12c22 100644 (file)
@@ -1174,7 +1174,9 @@ function elgg_dump($value, $to_screen = TRUE, $level = 'NOTICE') {
  *
  * This function either displays or logs the deprecation message,
  * depending upon the deprecation policies in {@link CODING.txt}.
- * Logged messages are sent with the level of 'WARNING'.
+ * Logged messages are sent with the level of 'WARNING'. Only admins
+ * get visual deprecation notices. When non-admins are logged in, the
+ * notices are sent to PHP's log through elgg_dump().
  *
  * A user-visual message will be displayed if $dep_version is greater
  * than 1 minor releases lower than the current Elgg version, or at all
@@ -1185,11 +1187,12 @@ function elgg_dump($value, $to_screen = TRUE, $level = 'NOTICE') {
  *
  * @see CODING.txt
  *
- * @param str $msg             Message to log / display.
- * @param str $dep_version     Human-readable *release* version: 1.7, 1.8, ...
- * @param int $backtrace_level How many levels back to display the backtrace. Useful if calling from
- *                             functions that are called from other places (like elgg_view()). Set
- *                             to -1 for a full backtrace.
+ * @param string $msg             Message to log / display.
+ * @param string $dep_version     Human-readable *release* version: 1.7, 1.8, ...
+ * @param int    $backtrace_level How many levels back to display the backtrace.
+ *                                Useful if calling from functions that are called
+ *                                from other places (like elgg_view()). Set to -1
+ *                                for a full backtrace.
  *
  * @return bool
  * @since 1.7.0
@@ -1198,13 +1201,13 @@ function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) {
        // if it's a major release behind, visual and logged
        // if it's a 1 minor release behind, visual and logged
        // if it's for current minor release, logged.
-       // bugfixes don't matter because you're not deprecating between them, RIGHT?
+       // bugfixes don't matter because we are not deprecating between them
 
        if (!$dep_version) {
-               return FALSE;
+               return false;
        }
 
-       $elgg_version = get_version(TRUE);
+       $elgg_version = get_version(true);
        $elgg_version_arr = explode('.', $elgg_version);
        $elgg_major_version = (int)$elgg_version_arr[0];
        $elgg_minor_version = (int)$elgg_version_arr[1];
@@ -1212,16 +1215,16 @@ function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) {
        $dep_major_version = (int)$dep_version;
        $dep_minor_version = 10 * ($dep_version - $dep_major_version);
 
-       $visual = FALSE;
+       $visual = false;
 
        if (($dep_major_version < $elgg_major_version) ||
                ($dep_minor_version < $elgg_minor_version)) {
-               $visual = TRUE;
+               $visual = true;
        }
 
        $msg = "Deprecated in $dep_major_version.$dep_minor_version: $msg";
 
-       if ($visual) {
+       if ($visual && elgg_is_admin_logged_in()) {
                register_error($msg);
        }
 
@@ -1249,9 +1252,9 @@ function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) {
 
        $msg .= implode("<br /> -> ", $stack);
 
-       elgg_log($msg, 'WARNING');
+       elgg_dump($msg, elgg_is_admin_logged_in(), 'WARNING');
 
-       return TRUE;
+       return true;
 }
 
 /**