Add support for a second argument to wfDeprecated so we can start using it right...
authorDaniel Friesen <dantman@users.mediawiki.org>
Thu, 15 Sep 2011 02:10:44 +0000 (02:10 +0000)
committerDaniel Friesen <dantman@users.mediawiki.org>
Thu, 15 Sep 2011 02:10:44 +0000 (02:10 +0000)
includes/DefaultSettings.php
includes/GlobalFunctions.php

index 4b69e71..c407aff 100644 (file)
@@ -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;
 
index 6b46c3f..d7a55c9 100644 (file)
@@ -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 );
+               }
        }
 }