Deprecate setting Parser::mTitle to null

This never happens in core code; however extensions have slipped into
a state of sin.

Bug: T235392
Change-Id: Ia254949cd8b3bc162b11dcc911dcce40d91bf1b7
This commit is contained in:
C. Scott Ananian 2019-10-17 12:59:04 -04:00
parent b1a8bd2264
commit dd9e6124b4
2 changed files with 13 additions and 1 deletions

View file

@ -620,6 +620,9 @@ because of Phabricator reports.
fetchLanguageName, getFileName, getMessagesFileName, getJsonMessagesFileName.
Use the new LanguageNameUtils class instead. (Note that fetchLanguageName(s)
are called getLanguageName(s) in the new class.)
* Using the Parser without initializing its $mTitle property to non-null has
been deprecated. In a future release Parser::getTitle() will throw a
TypeError if $mTitle is uninitialized.
=== Other changes in 1.34 ===
* Added option to specify "Various authors" as author in extension credits using

View file

@ -228,7 +228,11 @@ class Parser {
public $mOptions;
/**
* @var Title|null Beware - this is not always set
* Since 1.34, leaving `mTitle` uninitialized or setting `mTitle` to
* `null` is deprecated.
*
* @internal
* @var Title|null
*/
public $mTitle; # Title context, used for self-link rendering and similar things
public $mOutputType; # Output type, one of the OT_xxx constants
@ -922,9 +926,14 @@ class Parser {
/**
* Accessor for the Title object
*
* Since 1.34, leaving `mTitle` uninitialized as `null` is deprecated.
*
* @return Title|null
*/
public function getTitle() : ?Title {
if ( $this->mTitle === null ) {
wfDeprecated( 'Parser title should never be null', '1.34' );
}
return $this->mTitle;
}