$this->mPreprocessorClass = $conf['preprocessorClass'];
} elseif ( defined( 'HPHP_VERSION' ) ) {
# Preprocessor_Hash is much faster than Preprocessor_DOM under HipHop
- $this->mPreprocessorClass = 'Preprocessor_Hash';
+ $this->mPreprocessorClass = Preprocessor_Hash::class;
} elseif ( extension_loaded( 'domxml' ) ) {
# PECL extension that conflicts with the core DOM extension (T15770)
wfDebug( "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n" );
- $this->mPreprocessorClass = 'Preprocessor_Hash';
+ $this->mPreprocessorClass = Preprocessor_Hash::class;
} elseif ( extension_loaded( 'dom' ) ) {
- $this->mPreprocessorClass = 'Preprocessor_DOM';
+ $this->mPreprocessorClass = Preprocessor_DOM::class;
} else {
- $this->mPreprocessorClass = 'Preprocessor_Hash';
+ $this->mPreprocessorClass = Preprocessor_Hash::class;
}
wfDebug( __CLASS__ . ": using preprocessor: {$this->mPreprocessorClass}\n" );
}
$this->mLangLinkLanguages = [];
$this->currentRevisionCache = null;
- $this->mStripState = new StripState;
+ $this->mStripState = new StripState( $this );
# Clear these on every parse, T6549
$this->mTplRedirCache = $this->mTplDomCache = [];
$this->mOutput->setLimitReportData( 'limitreport-expensivefunctioncount',
[ $this->mExpensiveFunctionCount, $this->mOptions->getExpensiveParserFunctionLimit() ]
);
+
+ foreach ( $this->mStripState->getLimitReport() as list( $key, $value ) ) {
+ $this->mOutput->setLimitReportData( $key, $value );
+ }
+
Hooks::run( 'ParserLimitReportPrepare', [ $this, $this->mOutput ] );
$limitReport = "NewPP limit report\n";
$link = $origLink;
}
- $unstrip = $this->mStripState->unstripNoWiki( $link );
- $nt = is_string( $unstrip ) ? Title::newFromText( $unstrip ) : null;
+ // \x7f isn't a default legal title char, so most likely strip
+ // markers will force us into the "invalid form" path above. But,
+ // just in case, let's assert that xmlish tags aren't valid in
+ // the title position.
+ $unstrip = $this->mStripState->killMarkers( $link );
+ $noMarkers = ( $unstrip === $link );
+
+ $nt = $noMarkers ? Title::newFromText( $link ) : null;
if ( $nt === null ) {
$s .= $prefix . '[[' . $line;
continue;
# Inhibit editsection links if requested in the page
if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
- $maybeShowEditLink = $showEditLink = false;
+ $maybeShowEditLink = false;
} else {
- $maybeShowEditLink = true; /* Actual presence will depend on ParserOptions option */
- $showEditLink = $this->mOptions->getEditSection();
- }
- if ( $showEditLink ) {
- $this->mOutput->setEditSectionTokens( true );
+ $maybeShowEditLink = true; /* Actual presence will depend on post-cache transforms */
}
# Get all headlines for numbering them and adding funky stuff like [edit]
* $this : caller
* $section : the section number
* &$sectionContent : ref to the content of the section
- * $showEditLinks : boolean describing whether this section has an edit link
+ * $maybeShowEditLinks : boolean describing whether this section has an edit link
*/
- Hooks::run( 'ParserSectionCreate', [ $this, $i, &$sections[$i], $showEditLink ] );
+ Hooks::run( 'ParserSectionCreate', [ $this, $i, &$sections[$i], $maybeShowEditLink ] );
$i++;
}
# Special case; width and height come in one variable together
if ( $type === 'handler' && $paramName === 'width' ) {
- $parsedWidthParam = $this->parseWidthParam( $value );
+ $parsedWidthParam = self::parseWidthParam( $value );
if ( isset( $parsedWidthParam['width'] ) ) {
$width = $parsedWidthParam['width'];
if ( $handler->validateParam( 'width', $width ) ) {
* unserializeHalfParsedText(). The text can then be safely incorporated into
* the return value of a parser hook.
*
+ * @deprecated since 1.31
* @param string $text
*
* @return array
*/
public function serializeHalfParsedText( $text ) {
+ wfDeprecated( __METHOD__, '1.31' );
$data = [
'text' => $text,
'version' => self::HALF_PARSED_VERSION,
* If the $data array has been stored persistently, the caller should first
* check whether it is still valid, by calling isValidHalfParsedText().
*
+ * @deprecated since 1.31
* @param array $data Serialized data
* @throws MWException
* @return string
*/
public function unserializeHalfParsedText( $data ) {
+ wfDeprecated( __METHOD__, '1.31' );
if ( !isset( $data['version'] ) || $data['version'] != self::HALF_PARSED_VERSION ) {
throw new MWException( __METHOD__ . ': invalid version' );
}
* serializeHalfParsedText(), is compatible with the current version of the
* parser.
*
+ * @deprecated since 1.31
* @param array $data
*
* @return bool
*/
public function isValidHalfParsedText( $data ) {
+ wfDeprecated( __METHOD__, '1.31' );
return isset( $data['version'] ) && $data['version'] == self::HALF_PARSED_VERSION;
}
* Parsed a width param of imagelink like 300px or 200x300px
*
* @param string $value
+ * @param bool $parseHeight
*
* @return array
* @since 1.20
*/
- public function parseWidthParam( $value ) {
+ public static function parseWidthParam( $value, $parseHeight = true ) {
$parsedWidthParam = [];
if ( $value === '' ) {
return $parsedWidthParam;
$m = [];
# (T15500) In both cases (width/height and width only),
# permit trailing "px" for backward compatibility.
- if ( preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
+ if ( $parseHeight && preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m ) ) {
$width = intval( $m[1] );
$height = intval( $m[2] );
$parsedWidthParam['width'] = $width;