Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1002,12 +1002,13 @@ |
1003 | 1003 | * Throws a warning that $function is deprecated |
1004 | 1004 | * |
1005 | 1005 | * @param $function String |
1006 | | - * @param $version String|bool: Added in 1.19. |
| 1006 | + * @param $version String|bool: Version of MediaWiki that the function was deprecated in (Added in 1.19). |
1007 | 1007 | * @param $component String|bool: Added in 1.19. |
| 1008 | + * @param $callerOffset integer: How far up the callstack is the original caller (Added in 1.20) |
1008 | 1009 | * |
1009 | 1010 | * @return null |
1010 | 1011 | */ |
1011 | | -function wfDeprecated( $function, $version = false, $component = false ) { |
| 1012 | +function wfDeprecated( $function, $version = false, $component = false, $callerOffset = 2 ) { |
1012 | 1013 | static $functionsWarned = array(); |
1013 | 1014 | |
1014 | 1015 | MWDebug::deprecated( $function, $version, $component ); |
— | — | @@ -1032,9 +1033,9 @@ |
1033 | 1034 | } |
1034 | 1035 | |
1035 | 1036 | $component = $component === false ? 'MediaWiki' : $component; |
1036 | | - wfWarn( "Use of $function was deprecated in $component $version.", 2 ); |
| 1037 | + wfWarn( "Use of $function was deprecated in $component $version.", $callerOffset ); |
1037 | 1038 | } else { |
1038 | | - wfWarn( "Use of $function is deprecated.", 2 ); |
| 1039 | + wfWarn( "Use of $function is deprecated.", $callerOffset ); |
1039 | 1040 | } |
1040 | 1041 | } |
1041 | 1042 | } |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -53,6 +53,7 @@ |
54 | 54 | 'DBDataObject' => 'includes/DBDataObject.php', |
55 | 55 | 'DeferrableUpdate' => 'includes/DeferredUpdates.php', |
56 | 56 | 'DeferredUpdates' => 'includes/DeferredUpdates.php', |
| 57 | + 'DeprecatedGlobal' => 'includes/DeprecatedGlobal.php', |
57 | 58 | 'DerivativeRequest' => 'includes/WebRequest.php', |
58 | 59 | 'DiffHistoryBlob' => 'includes/HistoryBlob.php', |
59 | 60 | |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -272,7 +272,7 @@ |
273 | 273 | * @deprecated since 1.18 |
274 | 274 | */ |
275 | 275 | global $wgArticle; |
276 | | - $wgArticle = $article; |
| 276 | + $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' ); |
277 | 277 | |
278 | 278 | $this->performAction( $article ); |
279 | 279 | } elseif ( is_string( $article ) ) { |
Index: trunk/phase3/includes/DeprecatedGlobal.php |
— | — | @@ -0,0 +1,22 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Class to allow throwing wfDeprecated warnings |
| 5 | + * when people use globals that we do not want them to. |
| 6 | + * (For example like $wgArticle) |
| 7 | + */ |
| 8 | + |
| 9 | +class DeprecatedGlobal extends StubObject { |
| 10 | + // The m's are to stay consistent with parent class. |
| 11 | + protected $mRealValue, $mVersion; |
| 12 | + |
| 13 | + function __construct( $name, $realValue, $version = false ) { |
| 14 | + parent::__construct( $name ); |
| 15 | + $this->mRealValue = $realValue; |
| 16 | + $this->mVersion = $version; |
| 17 | + } |
| 18 | + |
| 19 | + function _newObject() { |
| 20 | + wfDeprecated( '$' . $this->mGlobal, $this->mVersion, false, 6 ); |
| 21 | + return $this->mRealValue; |
| 22 | + } |
| 23 | +} |
Property changes on: trunk/phase3/includes/DeprecatedGlobal.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 24 | + native |