From 98aa14bc87b89bee48101e15f2423ad3072a1af7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sat, 23 May 2009 10:14:24 +0000 Subject: [PATCH] * $wgDevelopmentWarnings can be set to true to show warnings about deprecated functions and other potential errors when developing. * (bug 14118) SpecialPage::getTitleFor does not return a localised name --- RELEASE-NOTES | 3 +++ includes/DefaultSettings.php | 6 ++++++ includes/GlobalFunctions.php | 26 +++++++++++++++----------- includes/SpecialPage.php | 12 ++++++++++++ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b6d3920810..df25b9cb21 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9b3fd4bbbd..393ac1df71 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 */ diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 59fcf48a27..aa44d5e6ad 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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" ); } /** diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index bfba9add4f..e6e2c8dfd3 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -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"; -- 2.20.1