r110648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110647‎ | r110648 | r110649 >
Date:09:54, 3 February 2012
Author:ialex
Status:ok
Tags:
Comment:
Moved wfDeprecated() and wfWarn() near other debug-related functions
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -977,6 +977,88 @@
978978 }
979979
980980 /**
 981+ * Throws a warning that $function is deprecated
 982+ *
 983+ * @param $function String
 984+ * @param $version String|false: Added in 1.19.
 985+ * @param $component String|false: Added in 1.19.
 986+ *
 987+ * @return null
 988+ */
 989+function wfDeprecated( $function, $version = false, $component = false ) {
 990+ static $functionsWarned = array();
 991+
 992+ MWDebug::deprecated( $function, $version, $component );
 993+
 994+ if ( !isset( $functionsWarned[$function] ) ) {
 995+ $functionsWarned[$function] = true;
 996+
 997+ if ( $version ) {
 998+ global $wgDeprecationReleaseLimit;
 999+
 1000+ if ( $wgDeprecationReleaseLimit && $component === false ) {
 1001+ # Strip -* off the end of $version so that branches can use the
 1002+ # format #.##-branchname to avoid issues if the branch is merged into
 1003+ # a version of MediaWiki later than what it was branched from
 1004+ $comparableVersion = preg_replace( '/-.*$/', '', $version );
 1005+
 1006+ # If the comparableVersion is larger than our release limit then
 1007+ # skip the warning message for the deprecation
 1008+ if ( version_compare( $wgDeprecationReleaseLimit, $comparableVersion, '<' ) ) {
 1009+ return;
 1010+ }
 1011+ }
 1012+
 1013+ $component = $component === false ? 'MediaWiki' : $component;
 1014+ wfWarn( "Use of $function was deprecated in $component $version.", 2 );
 1015+ } else {
 1016+ wfWarn( "Use of $function is deprecated.", 2 );
 1017+ }
 1018+ }
 1019+}
 1020+
 1021+/**
 1022+ * Send a warning either to the debug log or in a PHP error depending on
 1023+ * $wgDevelopmentWarnings
 1024+ *
 1025+ * @param $msg String: message to send
 1026+ * @param $callerOffset Integer: number of items to go back in the backtrace to
 1027+ * find the correct caller (1 = function calling wfWarn, ...)
 1028+ * @param $level Integer: PHP error level; only used when $wgDevelopmentWarnings
 1029+ * is true
 1030+ */
 1031+function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
 1032+ global $wgDevelopmentWarnings;
 1033+
 1034+ MWDebug::warning( $msg, $callerOffset + 2 );
 1035+
 1036+ $callers = wfDebugBacktrace();
 1037+ if ( isset( $callers[$callerOffset + 1] ) ) {
 1038+ $callerfunc = $callers[$callerOffset + 1];
 1039+ $callerfile = $callers[$callerOffset];
 1040+ if ( isset( $callerfile['file'] ) && isset( $callerfile['line'] ) ) {
 1041+ $file = $callerfile['file'] . ' at line ' . $callerfile['line'];
 1042+ } else {
 1043+ $file = '(internal function)';
 1044+ }
 1045+ $func = '';
 1046+ if ( isset( $callerfunc['class'] ) ) {
 1047+ $func .= $callerfunc['class'] . '::';
 1048+ }
 1049+ if ( isset( $callerfunc['function'] ) ) {
 1050+ $func .= $callerfunc['function'];
 1051+ }
 1052+ $msg .= " [Called from $func in $file]";
 1053+ }
 1054+
 1055+ if ( $wgDevelopmentWarnings ) {
 1056+ trigger_error( $msg, $level );
 1057+ } else {
 1058+ wfDebug( "$msg\n" );
 1059+ }
 1060+}
 1061+
 1062+/**
9811063 * Log to a file without getting "file size exceeded" signals.
9821064 *
9831065 * Can also log to TCP or UDP with the syntax udp://host:port/prefix. This will
@@ -3479,88 +3561,6 @@
34803562 }
34813563
34823564 /**
3483 - * Throws a warning that $function is deprecated
3484 - *
3485 - * @param $function String
3486 - * @param $version String|false: Added in 1.19.
3487 - * @param $component String|false: Added in 1.19.
3488 - *
3489 - * @return null
3490 - */
3491 -function wfDeprecated( $function, $version = false, $component = false ) {
3492 - static $functionsWarned = array();
3493 -
3494 - MWDebug::deprecated( $function, $version, $component );
3495 -
3496 - if ( !isset( $functionsWarned[$function] ) ) {
3497 - $functionsWarned[$function] = true;
3498 -
3499 - if ( $version ) {
3500 - global $wgDeprecationReleaseLimit;
3501 -
3502 - if ( $wgDeprecationReleaseLimit && $component === false ) {
3503 - # Strip -* off the end of $version so that branches can use the
3504 - # format #.##-branchname to avoid issues if the branch is merged into
3505 - # a version of MediaWiki later than what it was branched from
3506 - $comparableVersion = preg_replace( '/-.*$/', '', $version );
3507 -
3508 - # If the comparableVersion is larger than our release limit then
3509 - # skip the warning message for the deprecation
3510 - if ( version_compare( $wgDeprecationReleaseLimit, $comparableVersion, '<' ) ) {
3511 - return;
3512 - }
3513 - }
3514 -
3515 - $component = $component === false ? 'MediaWiki' : $component;
3516 - wfWarn( "Use of $function was deprecated in $component $version.", 2 );
3517 - } else {
3518 - wfWarn( "Use of $function is deprecated.", 2 );
3519 - }
3520 - }
3521 -}
3522 -
3523 -/**
3524 - * Send a warning either to the debug log or in a PHP error depending on
3525 - * $wgDevelopmentWarnings
3526 - *
3527 - * @param $msg String: message to send
3528 - * @param $callerOffset Integer: number of items to go back in the backtrace to
3529 - * find the correct caller (1 = function calling wfWarn, ...)
3530 - * @param $level Integer: PHP error level; only used when $wgDevelopmentWarnings
3531 - * is true
3532 - */
3533 -function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
3534 - global $wgDevelopmentWarnings;
3535 -
3536 - MWDebug::warning( $msg, $callerOffset + 2 );
3537 -
3538 - $callers = wfDebugBacktrace();
3539 - if ( isset( $callers[$callerOffset + 1] ) ) {
3540 - $callerfunc = $callers[$callerOffset + 1];
3541 - $callerfile = $callers[$callerOffset];
3542 - if ( isset( $callerfile['file'] ) && isset( $callerfile['line'] ) ) {
3543 - $file = $callerfile['file'] . ' at line ' . $callerfile['line'];
3544 - } else {
3545 - $file = '(internal function)';
3546 - }
3547 - $func = '';
3548 - if ( isset( $callerfunc['class'] ) ) {
3549 - $func .= $callerfunc['class'] . '::';
3550 - }
3551 - if ( isset( $callerfunc['function'] ) ) {
3552 - $func .= $callerfunc['function'];
3553 - }
3554 - $msg .= " [Called from $func in $file]";
3555 - }
3556 -
3557 - if ( $wgDevelopmentWarnings ) {
3558 - trigger_error( $msg, $level );
3559 - } else {
3560 - wfDebug( "$msg\n" );
3561 - }
3562 -}
3563 -
3564 -/**
35653565 * Modern version of wfWaitForSlaves(). Instead of looking at replication lag
35663566 * and waiting for it to go down, this waits for the slaves to catch up to the
35673567 * master position. Use this when updating very large numbers of rows, as

Status & tagging log