See discussion on r111168.
Of course no one will see warning because trunk has $wgDeprecationReleaseLimit set to 1.17 by default
(<rant>have I mentioned how I don't like that variable. People enable warnings to be *warned* about
things. Making it so people won't get warned about things until a couple months after we've decided people
should stop using function/interface/etc defeats the purpose of having warnings</rant>)
p.s. Wasn't sure if this waranted something in the release notes, I don't think it does (It's just adding a warning)
but wasn't sure.
'DBDataObject' => 'includes/DBDataObject.php',
'DeferrableUpdate' => 'includes/DeferredUpdates.php',
'DeferredUpdates' => 'includes/DeferredUpdates.php',
+ 'DeprecatedGlobal' => 'includes/DeprecatedGlobal.php',
'DerivativeRequest' => 'includes/WebRequest.php',
'DiffHistoryBlob' => 'includes/HistoryBlob.php',
--- /dev/null
+<?php
+/**
+ * Class to allow throwing wfDeprecated warnings
+ * when people use globals that we do not want them to.
+ * (For example like $wgArticle)
+ */
+
+class DeprecatedGlobal extends StubObject {
+ // The m's are to stay consistent with parent class.
+ protected $mRealValue, $mVersion;
+
+ function __construct( $name, $realValue, $version = false ) {
+ parent::__construct( $name );
+ $this->mRealValue = $realValue;
+ $this->mVersion = $version;
+ }
+
+ function _newObject() {
+ wfDeprecated( '$' . $this->mGlobal, $this->mVersion, false, 6 );
+ return $this->mRealValue;
+ }
+}
* Throws a warning that $function is deprecated
*
* @param $function String
- * @param $version String|bool: Added in 1.19.
+ * @param $version String|bool: Version of MediaWiki that the function was deprecated in (Added in 1.19).
* @param $component String|bool: Added in 1.19.
+ * @param $callerOffset integer: How far up the callstack is the original caller (Added in 1.20)
*
* @return null
*/
-function wfDeprecated( $function, $version = false, $component = false ) {
+function wfDeprecated( $function, $version = false, $component = false, $callerOffset = 2 ) {
static $functionsWarned = array();
MWDebug::deprecated( $function, $version, $component );
}
$component = $component === false ? 'MediaWiki' : $component;
- wfWarn( "Use of $function was deprecated in $component $version.", 2 );
+ wfWarn( "Use of $function was deprecated in $component $version.", $callerOffset );
} else {
- wfWarn( "Use of $function is deprecated.", 2 );
+ wfWarn( "Use of $function is deprecated.", $callerOffset );
}
}
}
* @deprecated since 1.18
*/
global $wgArticle;
- $wgArticle = $article;
+ $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' );
$this->performAction( $article );
} elseif ( is_string( $article ) ) {