X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FParserOutput.php;h=6c7ad4eb4c14bfafc2aa5fe1dbb33a3cbac22df7;hb=5fd224c00b940f75c1f83e56b99961be94bde70a;hp=3a35e042a77dda91d76737cbbf00d628dee80a11;hpb=a0e11fff0c12b73aa2d9083b32a066f61e55399e;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php
index 3a35e042a7..6c7ad4eb4c 100644
--- a/includes/parser/ParserOutput.php
+++ b/includes/parser/ParserOutput.php
@@ -41,7 +41,7 @@ class ParserOutput extends CacheTime {
/**
* @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.
@@ -52,40 +52,40 @@ class ParserOutput extends CacheTime {
* @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?
@@ -105,43 +105,43 @@ class ParserOutput extends CacheTime {
/**
* @var array $mHeadItems Items to put in the
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.
@@ -151,7 +151,7 @@ class ParserOutput extends CacheTime {
/**
* @var array $mProperties Name/value pairs to be cached in the DB.
*/
- public $mProperties = array();
+ public $mProperties = [];
/**
* @var string $mTOCHTML HTML of the TOC.
@@ -181,22 +181,22 @@ class ParserOutput extends CacheTime {
/**
* @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();
+ private $mLimitReportData = [];
/**
* @var array $mParseStartTime Timestamps for getTimeSinceStart().
*/
- private $mParseStartTime = array();
+ private $mParseStartTime = [];
/**
* @var bool $mPreventClickjacking Whether to emit X-Frame-Options: DENY.
@@ -206,12 +206,12 @@ class ParserOutput extends CacheTime {
/**
* @var array $mFlags Generic flags.
*/
- private $mFlags = array();
+ private $mFlags = [];
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;
@@ -220,6 +220,17 @@ class ParserOutput extends CacheTime {
$this->mTitleText = $titletext;
}
+ /**
+ * Get the cacheable text with markers still in it. The
+ * return value is suitable for writing back via setText() but is not valid
+ * for display to the user.
+ *
+ * @since 1.27
+ */
+ public function getRawText() {
+ return $this->mText;
+ }
+
public function getText() {
$text = $this->mText;
if ( $this->mEditSectionTokens ) {
@@ -237,9 +248,9 @@ class ParserOutput extends CacheTime {
$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
@@ -250,7 +261,7 @@ class ParserOutput extends CacheTime {
// 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',
@@ -346,7 +357,7 @@ class ParserOutput extends CacheTime {
*/
public function getModuleMessages() {
wfDeprecated( __METHOD__, '1.26' );
- return array();
+ return [];
}
/** @since 1.23 */
@@ -370,6 +381,9 @@ class ParserOutput extends CacheTime {
return $this->mTOCHTML;
}
+ /**
+ * @return string|null TS_MW timestamp of the revision content
+ */
public function getTimestamp() {
return $this->mTimestamp;
}
@@ -457,7 +471,7 @@ class ParserOutput extends CacheTime {
}
public function addOutputHook( $hook, $data = false ) {
- $this->mOutputHooks[] = array( $hook, $data );
+ $this->mOutputHooks[] = [ $hook, $data ];
}
public function setNewSection( $value ) {
@@ -530,7 +544,7 @@ class ParserOutput extends CacheTime {
return;
}
if ( !isset( $this->mLinks[$ns] ) ) {
- $this->mLinks[$ns] = array();
+ $this->mLinks[$ns] = [];
}
if ( is_null( $id ) ) {
$id = $title->getArticleID();
@@ -548,7 +562,7 @@ class ParserOutput extends CacheTime {
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 ];
}
}
@@ -563,11 +577,11 @@ class ParserOutput extends CacheTime {
$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
}
@@ -582,7 +596,7 @@ class ParserOutput extends CacheTime {
}
$prefix = $title->getInterwiki();
if ( !isset( $this->mInterwikiLinks[$prefix] ) ) {
- $this->mInterwikiLinks[$prefix] = array();
+ $this->mInterwikiLinks[$prefix] = [];
}
$this->mInterwikiLinks[$prefix][$title->getDBkey()] = 1;
}
@@ -822,7 +836,7 @@ class ParserOutput extends CacheTime {
public function getProperties() {
if ( !isset( $this->mProperties ) ) {
- $this->mProperties = array();
+ $this->mProperties = [];
}
return $this->mProperties;
}
@@ -834,7 +848,7 @@ class ParserOutput extends CacheTime {
*/
public function getUsedOptions() {
if ( !isset( $this->mAccessedOptions ) ) {
- return array();
+ return [];
}
return array_keys( $this->mAccessedOptions );
}
@@ -855,49 +869,6 @@ class ParserOutput extends CacheTime {
$this->mAccessedOptions[$option] = true;
}
- /**
- * @deprecated since 1.25. Instead, store any relevant data using setExtensionData,
- * and implement Content::getSecondaryDataUpdates() if possible, or use the
- * 'SecondaryDataUpdates' hook to construct the necessary update objects.
- *
- * @note Hard deprecation and removal without long deprecation period, since there are no
- * known users, but known conceptual issues.
- *
- * @todo remove in 1.26
- *
- * @param DataUpdate $update
- *
- * @throws MWException
- */
- public function addSecondaryDataUpdate( DataUpdate $update ) {
- wfDeprecated( __METHOD__, '1.25' );
- throw new MWException(
- 'ParserOutput::addSecondaryDataUpdate() is no longer supported. ' .
- 'Override Content::getSecondaryDataUpdates() ' .
- 'or use the SecondaryDataUpdates hook instead.'
- );
- }
-
- /**
- * @deprecated since 1.25. Instead, store any relevant data using setExtensionData,
- * and implement Content::getSecondaryDataUpdates() if possible, or use the
- * 'SecondaryDataUpdates' hook to construct the necessary update objects.
- *
- * @note Hard deprecation and removal without long deprecation period, since there are no
- * known users, but known conceptual issues.
- *
- * @todo remove in 1.26
- *
- * @param Title $title
- * @param bool $recursive
- *
- * @return array An array of instances of DataUpdate
- */
- public function getSecondaryDataUpdates( Title $title = null, $recursive = true ) {
- wfDeprecated( __METHOD__, '1.25' );
- return array();
- }
-
/**
* Attaches arbitrary data to this ParserObject. This can be used to store some information in
* the ParserOutput object for later use during page output. The data will be cached along with
@@ -966,7 +937,7 @@ class ParserOutput extends CacheTime {
}
private static function getTimes( $clock = null ) {
- $ret = array();
+ $ret = [];
if ( !$clock || $clock === 'wall' ) {
$ret['wall'] = microtime( true );
}
@@ -1065,7 +1036,7 @@ class ParserOutput extends CacheTime {
public function __sleep() {
return array_diff(
array_keys( get_object_vars( $this ) ),
- array( 'mParseStartTime' )
+ [ 'mParseStartTime' ]
);
}
}