r97136 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97135‎ | r97136 | r97137 >
Date:02:10, 15 September 2011
Author:dantman
Status:ok (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -3335,13 +3335,30 @@
33363336 * Throws a warning that $function is deprecated
33373337 *
33383338 * @param $function String
 3339+ * @param $version String
33393340 * @return null
33403341 */
3341 -function wfDeprecated( $function ) {
 3342+function wfDeprecated( $function, $version=false ) {
33423343 static $functionsWarned = array();
33433344 if ( !isset( $functionsWarned[$function] ) ) {
33443345 $functionsWarned[$function] = true;
3345 - wfWarn( "Use of $function is deprecated.", 2 );
 3346+ if ( $version ) {
 3347+ global $wgDeprecationReleaseLimit;
 3348+ if ( $wgDeprecationReleaseLimit ) {
 3349+ # Strip -* off the end of $version so that branches can use the
 3350+ # format #.##-branchname to avoid issues if the branch is merged into
 3351+ # a version of MediaWiki later than what it was branched from
 3352+ $comparableVersion = preg_replace( '/-.*$/', '', $version );
 3353+ # If the comparableVersion is larger than our release limit then
 3354+ # skip the warning message for the deprecation
 3355+ if ( version_compare( $wgDeprecationReleaseLimit, $comparableVersion, '<' ) ) {
 3356+ return;
 3357+ }
 3358+ }
 3359+ wfWarn( "Use of $function was deprecated in $version.", 2 );
 3360+ } else {
 3361+ wfWarn( "Use of $function is deprecated.", 2 );
 3362+ }
33463363 }
33473364 }
33483365
Index: trunk/phase3/includes/DefaultSettings.php
@@ -4039,6 +4039,13 @@
40404040 */
40414041 $wgDevelopmentWarnings = false;
40424042
 4043+/**
 4044+ * Release limitation to wfDeprecated warnings, if set to a release number
 4045+ * development warnings will not be generated for deprecations added in releases
 4046+ * after the limit.
 4047+ */
 4048+$wgDeprecationReleaseLimit = false;
 4049+
40434050 /** Only record profiling info for pages that took longer than this */
40444051 $wgProfileLimit = 0.0;
40454052

Follow-up revisions

RevisionCommit summaryAuthorDate
r97173Merged revisions 97087,97091-97092,97094,97096-97098,97100-97101,97103,97136,...dantman16:19, 15 September 2011
r97445Minor whitespace fixes in GlobalFunctions.php...krinkle23:21, 18 September 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:43, 15 September 2011
+function wfDeprecated( $function, $version=false ) {

Moar spaces!

Status & tagging log