From: Daniel Friesen Date: Thu, 15 Sep 2011 02:10:44 +0000 (+0000) Subject: Add support for a second argument to wfDeprecated so we can start using it right... X-Git-Tag: 1.31.0-rc.0~27653 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=738e98cc5621389a54c0d38c122602a8f072408c;p=lhc%2Fweb%2Fwiklou.git Add support for a second argument to wfDeprecated so we can start using it right away and let users limit what warnings they get if they need to, instead of delaying warnings for an entire release or more. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4b69e7188e..c407aff0fd 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4039,6 +4039,13 @@ $wgShowHostnames = false; */ $wgDevelopmentWarnings = false; +/** + * Release limitation to wfDeprecated warnings, if set to a release number + * development warnings will not be generated for deprecations added in releases + * after the limit. + */ +$wgDeprecationReleaseLimit = false; + /** Only record profiling info for pages that took longer than this */ $wgProfileLimit = 0.0; diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 6b46c3f68f..d7a55c9384 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3335,13 +3335,30 @@ function wfGetNull() { * Throws a warning that $function is deprecated * * @param $function String + * @param $version String * @return null */ -function wfDeprecated( $function ) { +function wfDeprecated( $function, $version=false ) { static $functionsWarned = array(); if ( !isset( $functionsWarned[$function] ) ) { $functionsWarned[$function] = true; - wfWarn( "Use of $function is deprecated.", 2 ); + if ( $version ) { + global $wgDeprecationReleaseLimit; + if ( $wgDeprecationReleaseLimit ) { + # Strip -* off the end of $version so that branches can use the + # format #.##-branchname to avoid issues if the branch is merged into + # a version of MediaWiki later than what it was branched from + $comparableVersion = preg_replace( '/-.*$/', '', $version ); + # If the comparableVersion is larger than our release limit then + # skip the warning message for the deprecation + if ( version_compare( $wgDeprecationReleaseLimit, $comparableVersion, '<' ) ) { + return; + } + } + wfWarn( "Use of $function was deprecated in $version.", 2 ); + } else { + wfWarn( "Use of $function is deprecated.", 2 ); + } } }