/**
* @var array $mIndicators Page status indicators, usually displayed in top-right corner.
*/
- public $mIndicators = array();
+ public $mIndicators = [];
/**
* @var string $mTitleText Title text of the chosen language variant, as HTML.
* @var array $mLinks 2-D map of NS/DBK to ID for the links in the document.
* ID=zero for broken.
*/
- public $mLinks = array();
+ public $mLinks = [];
/**
* @var array $mTemplates 2-D map of NS/DBK to ID for the template references.
* ID=zero for broken.
*/
- public $mTemplates = array();
+ public $mTemplates = [];
/**
* @var array $mTemplateIds 2-D map of NS/DBK to rev ID for the template references.
* ID=zero for broken.
*/
- public $mTemplateIds = array();
+ public $mTemplateIds = [];
/**
* @var array $mImages DB keys of the images used, in the array key only
*/
- public $mImages = array();
+ public $mImages = [];
/**
* @var array $mFileSearchOptions DB keys of the images used mapped to sha1 and MW timestamp.
*/
- public $mFileSearchOptions = array();
+ public $mFileSearchOptions = [];
/**
* @var array $mExternalLinks External link URLs, in the key only.
*/
- public $mExternalLinks = array();
+ public $mExternalLinks = [];
/**
* @var array $mInterwikiLinks 2-D map of prefix/DBK (in keys only)
* for the inline interwiki links in the document.
*/
- public $mInterwikiLinks = array();
+ public $mInterwikiLinks = [];
/**
* @var bool $mNewSection Show a new section link?
/**
* @var array $mHeadItems Items to put in the <head> section
*/
- public $mHeadItems = array();
+ public $mHeadItems = [];
/**
* @var array $mModules Modules to be loaded by ResourceLoader
*/
- public $mModules = array();
+ public $mModules = [];
/**
* @var array $mModuleScripts Modules of which only the JS will be loaded by ResourceLoader.
*/
- public $mModuleScripts = array();
+ public $mModuleScripts = [];
/**
* @var array $mModuleStyles Modules of which only the CSSS will be loaded by ResourceLoader.
*/
- public $mModuleStyles = array();
+ public $mModuleStyles = [];
/**
* @var array $mJsConfigVars JavaScript config variable for mw.config combined with this page.
*/
- public $mJsConfigVars = array();
+ public $mJsConfigVars = [];
/**
* @var array $mOutputHooks Hook tags as per $wgParserOutputHooks.
*/
- public $mOutputHooks = array();
+ public $mOutputHooks = [];
/**
* @var array $mWarnings Warning text to be returned to the user.
* Wikitext formatted, in the key only.
*/
- public $mWarnings = array();
+ public $mWarnings = [];
/**
* @var array $mSections Table of contents
*/
- public $mSections = array();
+ public $mSections = [];
/**
* @var bool $mEditSectionTokens prefix/suffix markers if edit sections were output as tokens.
/**
* @var array $mProperties Name/value pairs to be cached in the DB.
*/
- public $mProperties = array();
+ public $mProperties = [];
/**
* @var string $mTOCHTML HTML of the TOC.
/**
* @var array $mAccessedOptions List of ParserOptions (stored in the keys).
*/
- private $mAccessedOptions = array();
+ private $mAccessedOptions = [];
/**
* @var array $mExtensionData extra data used by extensions.
*/
- private $mExtensionData = array();
+ private $mExtensionData = [];
- /**
- * @var array $mLimitReportData Parser limit report data.
- */
- private $mLimitReportData = array();
+ /** @var array $mLimitReportData Parser limit report data. */
+ private $mLimitReportData = [];
/**
* @var array $mParseStartTime Timestamps for getTimeSinceStart().
*/
- private $mParseStartTime = array();
+ private $mParseStartTime = [];
/**
* @var bool $mPreventClickjacking Whether to emit X-Frame-Options: DENY.
/**
* @var array $mFlags Generic flags.
*/
- private $mFlags = array();
+ private $mFlags = [];
+
+ /** @var integer|null Assumed rev ID for {{REVISIONID}} if no revision is set */
+ private $mSpeculativeRevId;
const EDITSECTION_REGEX =
'#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#';
- public function __construct( $text = '', $languageLinks = array(), $categoryLinks = array(),
+ public function __construct( $text = '', $languageLinks = [], $categoryLinks = [],
$unused = false, $titletext = ''
) {
$this->mText = $text;
$skin = $wgOut->getSkin();
return call_user_func_array(
- array( $skin, 'doEditSectionLink' ),
- array( $editsectionPage, $editsectionSection,
- $editsectionContent, $wgLang->getCode() )
+ [ $skin, 'doEditSectionLink' ],
+ [ $editsectionPage, $editsectionSection,
+ $editsectionContent, $wgLang->getCode() ]
);
},
$text
// If you have an old cached version of this class - sorry, you can't disable the TOC
if ( isset( $this->mTOCEnabled ) && $this->mTOCEnabled ) {
- $text = str_replace( array( Parser::TOC_START, Parser::TOC_END ), '', $text );
+ $text = str_replace( [ Parser::TOC_START, Parser::TOC_END ], '', $text );
} else {
$text = preg_replace(
'#' . preg_quote( Parser::TOC_START, '#' ) . '.*?' . preg_quote( Parser::TOC_END, '#' ) . '#s',
return $text;
}
+ /**
+ * @param integer $id
+ * @since 1.28
+ */
+ public function setSpeculativeRevIdUsed( $id ) {
+ $this->mSpeculativeRevId = $id;
+ }
+
+ /** @since 1.28 */
+ public function getSpeculativeRevIdUsed() {
+ return $this->mSpeculativeRevId;
+ }
+
public function &getLanguageLinks() {
return $this->mLanguageLinks;
}
return $this->mModuleStyles;
}
- /**
- * @deprecated since 1.26 Obsolete
- * @return array
- */
- public function getModuleMessages() {
- wfDeprecated( __METHOD__, '1.26' );
- return array();
- }
-
/** @since 1.23 */
public function getJsConfigVars() {
return $this->mJsConfigVars;
return $this->mTOCHTML;
}
+ /**
+ * @return string|null TS_MW timestamp of the revision content
+ */
public function getTimestamp() {
return $this->mTimestamp;
}
}
public function addOutputHook( $hook, $data = false ) {
- $this->mOutputHooks[] = array( $hook, $data );
+ $this->mOutputHooks[] = [ $hook, $data ];
}
public function setNewSection( $value ) {
return;
}
if ( !isset( $this->mLinks[$ns] ) ) {
- $this->mLinks[$ns] = array();
+ $this->mLinks[$ns] = [];
}
if ( is_null( $id ) ) {
$id = $title->getArticleID();
public function addImage( $name, $timestamp = null, $sha1 = null ) {
$this->mImages[$name] = 1;
if ( $timestamp !== null && $sha1 !== null ) {
- $this->mFileSearchOptions[$name] = array( 'time' => $timestamp, 'sha1' => $sha1 );
+ $this->mFileSearchOptions[$name] = [ 'time' => $timestamp, 'sha1' => $sha1 ];
}
}
$ns = $title->getNamespace();
$dbk = $title->getDBkey();
if ( !isset( $this->mTemplates[$ns] ) ) {
- $this->mTemplates[$ns] = array();
+ $this->mTemplates[$ns] = [];
}
$this->mTemplates[$ns][$dbk] = $page_id;
if ( !isset( $this->mTemplateIds[$ns] ) ) {
- $this->mTemplateIds[$ns] = array();
+ $this->mTemplateIds[$ns] = [];
}
$this->mTemplateIds[$ns][$dbk] = $rev_id; // For versioning
}
}
$prefix = $title->getInterwiki();
if ( !isset( $this->mInterwikiLinks[$prefix] ) ) {
- $this->mInterwikiLinks[$prefix] = array();
+ $this->mInterwikiLinks[$prefix] = [];
}
$this->mInterwikiLinks[$prefix][$title->getDBkey()] = 1;
}
$this->mModuleStyles = array_merge( $this->mModuleStyles, (array)$modules );
}
- /**
- * @deprecated since 1.26 Use addModules() instead
- * @param string|array $modules
- */
- public function addModuleMessages( $modules ) {
- wfDeprecated( __METHOD__, '1.26' );
- }
-
/**
* Add one or more variables to be set in mw.config in JavaScript.
*
public function getProperties() {
if ( !isset( $this->mProperties ) ) {
- $this->mProperties = array();
+ $this->mProperties = [];
}
return $this->mProperties;
}
*/
public function getUsedOptions() {
if ( !isset( $this->mAccessedOptions ) ) {
- return array();
+ return [];
}
return array_keys( $this->mAccessedOptions );
}
}
private static function getTimes( $clock = null ) {
- $ret = array();
+ $ret = [];
if ( !$clock || $clock === 'wall' ) {
$ret['wall'] = microtime( true );
}
/**
* Sets parser limit report data for a key
*
- * The key is used as the prefix for various messages used for formatting:
- * - $key: The label for the field in the limit report
- * - $key-value-text: Message used to format the value in the "NewPP limit
- * report" HTML comment. If missing, uses $key-format.
- * - $key-value-html: Message used to format the value in the preview
- * limit report table. If missing, uses $key-format.
- * - $key-value: Message used to format the value. If missing, uses "$1".
- *
- * Note that all values are interpreted as wikitext, and so should be
- * encoded with htmlspecialchars() as necessary, but should avoid complex
- * HTML for sanity of display in the "NewPP limit report" comment.
+ * If $value consist of a list of two floats, it will be interpreted as
+ * (actual value, maximum allowed value). The presence of a "-" in $key will cause
+ * the first part of the key to be interpreted as a namespace.
*
* @since 1.22
- * @param string $key Message key
- * @param mixed $value Appropriate for Message::params()
+ * @param string $key Data key
+ * @param mixed $value Data value One of (float, string, bool, JSON serializable array)
*/
public function setLimitReportData( $key, $value ) {
- $this->mLimitReportData[$key] = $value;
+ if ( is_array( $value ) ) {
+ if ( array_keys( $value ) === [ 0, 1 ]
+ && is_numeric( $value[0] )
+ && is_numeric( $value[1] )
+ ) {
+ $data = [ 'value' => $value[0], 'limit' => $value[1] ];
+ } else {
+ $data = $value;
+ }
+ } else {
+ $data = $value;
+ }
+
+ if ( strpos( $key, '-' ) ) {
+ list( $ns, $name ) = explode( '-', $key, 2 );
+ $this->mLimitReportData[$ns][$name] = $data;
+ } else {
+ $this->mLimitReportData[$key] = $data;
+ }
}
/**
public function __sleep() {
return array_diff(
array_keys( get_object_vars( $this ) ),
- array( 'mParseStartTime' )
+ [ 'mParseStartTime' ]
);
}
}