* $wgDevelopmentWarnings can be set to true to show warnings about deprecated
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sat, 23 May 2009 10:14:24 +0000 (10:14 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sat, 23 May 2009 10:14:24 +0000 (10:14 +0000)
  functions and other potential errors when developing.
* (bug 14118) SpecialPage::getTitleFor does not return a localised name

RELEASE-NOTES
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/SpecialPage.php

index b6d3920..df25b9c 100644 (file)
@@ -29,6 +29,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * $wgAllowRealName was deprecated in favor of $wgHiddenPrefs[] = 'realname',
   but the former is still retained for backwards-compatibility
 * (bug 9257) $wgRCMaxAge now defaults to three months
+* $wgDevelopmentWarnings can be set to true to show warnings about deprecated
+  functions and other potential errors when developing.
 
 === New features in 1.16 ===
 
@@ -147,6 +149,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 18432) Updated documentation for dumpBackup.php
 * Fix array logic in Sanitizer::removeHTMLtags so that it doesn't strip good tags
   that were redundantly defined.
+* (bug 14118) SpecialPage::getTitleFor does not return a localised name
 
 == API changes in 1.16 ==
 
index 9b3fd4b..393ac1d 100644 (file)
@@ -1087,6 +1087,12 @@ $wgShowExceptionDetails = false;
  */
 $wgShowHostnames = false;
 
+/**
+ * If set to true MediaWiki will throw notices for some possible error
+ * conditions and for deprecated functions.
+ */
+$wgDevelopmentWarnings = false;
+
 /**
  * Use experimental, DMOZ-like category browser
  */
index 59fcf48..aa44d5e 100644 (file)
@@ -3012,19 +3012,19 @@ function wfMaxlagError( $host, $lag, $maxLag ) {
 }
 
 /**
- * Throws an E_USER_NOTICE saying that $function is deprecated
+ * Throws a warning that $function is deprecated
  * @param string $function
  * @return null
  */
 function wfDeprecated( $function ) {
-       global $wgDebugLogFile;
-       if ( !$wgDebugLogFile ) {
-               return;
-       }
+       wfWarn( "Use of $function is deprecated.", 2 );
+}
+
+function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
        $callers = wfDebugBacktrace();
-       if( isset( $callers[2] ) ){
-               $callerfunc = $callers[2];
-               $callerfile = $callers[1];
+       if( isset( $callers[$callerOffset+1] ) ){
+               $callerfunc = $callers[$callerOffset+1];
+               $callerfile = $callers[$callerOffset];
                if( isset( $callerfile['file'] ) && isset( $callerfile['line'] ) ){
                        $file = $callerfile['file'] . ' at line ' . $callerfile['line'];
                } else {
@@ -3034,11 +3034,15 @@ function wfDeprecated( $function ) {
                if( isset( $callerfunc['class'] ) )
                        $func .= $callerfunc['class'] . '::';
                $func .= @$callerfunc['function'];
-               $msg = "Use of $function is deprecated. Called from $func in $file";
+               $msg .= " [Called from $func in $file]";
+       }
+
+       global $wgDevelopmentWarnings;
+       if ( $wgDevelopmentWarnings ) {
+               trigger_error( $msg, $level );
        } else {
-               $msg = "Use of $function is deprecated.";
+               wfDebug( "$msg\n" );
        }
-       wfDebug( "$msg\n" );
 }
 
 /**
index bfba9ad..e6e2c8d 100644 (file)
@@ -597,6 +597,18 @@ class SpecialPage
                $aliases = $wgContLang->getSpecialPageAliases();
                if ( isset( $aliases[$name][0] ) ) {
                        $name = $aliases[$name][0];
+               } else {
+                       // Try harder in case someone misspelled the correct casing
+                       $found = false;
+                       foreach ( $aliases as $n => $values ) {
+                               if ( strcasecmp( $name, $n ) === 0 ) {
+                                       wfWarn( "Found $n for $name with casefix" );
+                                       $name = $values[0];
+                                       $found = true;
+                                       break;
+                               }
+                       }
+                       if ( !$found ) wfWarn( "Did not found name for special page $name" );
                }
                if ( $subpage !== false && !is_null( $subpage ) ) {
                        $name = "$name/$subpage";