CoreTagHooks::register( $this );
$this->initialiseVariables();
- Hooks::run( 'ParserFirstCallInit', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserFirstCallInit', [ &$parser ] );
}
/**
$this->mProfiler = new SectionProfiler();
- Hooks::run( 'ParserClearState', [ &$this ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserClearState', [ &$parser ] );
}
/**
$this->mRevisionSize = null;
}
- Hooks::run( 'ParserBeforeStrip', [ &$this, &$text, &$this->mStripState ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserBeforeStrip', [ &$parser, &$text, &$this->mStripState ] );
# No more strip!
- Hooks::run( 'ParserAfterStrip', [ &$this, &$text, &$this->mStripState ] );
+ Hooks::run( 'ParserAfterStrip', [ &$parser, &$text, &$this->mStripState ] );
$text = $this->internalParse( $text );
- Hooks::run( 'ParserAfterParse', [ &$this, &$text, &$this->mStripState ] );
+ Hooks::run( 'ParserAfterParse', [ &$parser, &$text, &$this->mStripState ] );
$text = $this->internalParseHalfParsed( $text, true, $linestart );
* @return string UNSAFE half-parsed HTML
*/
public function recursiveTagParse( $text, $frame = false ) {
- Hooks::run( 'ParserBeforeStrip', [ &$this, &$text, &$this->mStripState ] );
- Hooks::run( 'ParserAfterStrip', [ &$this, &$text, &$this->mStripState ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserBeforeStrip', [ &$parser, &$text, &$this->mStripState ] );
+ Hooks::run( 'ParserAfterStrip', [ &$parser, &$text, &$this->mStripState ] );
$text = $this->internalParse( $text, false, $frame );
return $text;
}
if ( $revid !== null ) {
$this->mRevisionId = $revid;
}
- Hooks::run( 'ParserBeforeStrip', [ &$this, &$text, &$this->mStripState ] );
- Hooks::run( 'ParserAfterStrip', [ &$this, &$text, &$this->mStripState ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'ParserBeforeStrip', [ &$parser, &$text, &$this->mStripState ] );
+ Hooks::run( 'ParserAfterStrip', [ &$parser, &$text, &$this->mStripState ] );
$text = $this->replaceVariables( $text, $frame );
$text = $this->mStripState->unstripBoth( $text );
return $text;
$origText = $text;
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
# Hook to suspend the parser in this state
- if ( !Hooks::run( 'ParserBeforeInternalParse', [ &$this, &$text, &$this->mStripState ] ) ) {
+ if ( !Hooks::run( 'ParserBeforeInternalParse', [ &$parser, &$text, &$this->mStripState ] ) ) {
return $text;
}
$text = $this->replaceVariables( $text );
}
- Hooks::run( 'InternalParseBeforeSanitize', [ &$this, &$text, &$this->mStripState ] );
+ Hooks::run( 'InternalParseBeforeSanitize', [ &$parser, &$text, &$this->mStripState ] );
$text = Sanitizer::removeHTMLtags(
$text,
- [ &$this, 'attributeStripCallback' ],
+ [ $this, 'attributeStripCallback' ],
false,
array_keys( $this->mTransparentTagHooks ),
[],
- [ &$this, 'addTrackingCategory' ]
+ [ $this, 'addTrackingCategory' ]
);
- Hooks::run( 'InternalParseBeforeLinks', [ &$this, &$text, &$this->mStripState ] );
+ Hooks::run( 'InternalParseBeforeLinks', [ &$parser, &$text, &$this->mStripState ] );
# Tables need to come after variable replacement for things to work
# properly; putting them before other transformations should keep
private function internalParseHalfParsed( $text, $isMain = true, $linestart = true ) {
$text = $this->mStripState->unstripGeneral( $text );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
if ( $isMain ) {
- Hooks::run( 'ParserAfterUnstrip', [ &$this, &$text ] );
+ Hooks::run( 'ParserAfterUnstrip', [ &$parser, &$text ] );
}
# Clean up special characters, only run once, next-to-last before doBlockLevels
$text = $this->mStripState->unstripNoWiki( $text );
if ( $isMain ) {
- Hooks::run( 'ParserBeforeTidy', [ &$this, &$text ] );
+ Hooks::run( 'ParserBeforeTidy', [ &$parser, &$text ] );
}
$text = $this->replaceTransparentTags( $text );
}
if ( $isMain ) {
- Hooks::run( 'ParserAfterTidy', [ &$this, &$text ] );
+ Hooks::run( 'ParserAfterTidy', [ &$parser, &$text ] );
}
return $text;
(?: [0-9] $spdash? ){9} # 9 digits with opt. delimiters
[0-9Xx] # check digit
)\b
- )!xu", [ &$this, 'magicLinkCallback' ], $text );
+ )!xu", [ $this, 'magicLinkCallback' ], $text );
return $text;
}
return $attribs;
}
- /**
- * Replace unusual escape codes in a URL with their equivalent characters
- *
- * @deprecated since 1.24, use normalizeLinkUrl
- * @param string $url
- * @return string
- */
- public static function replaceUnusualEscapes( $url ) {
- wfDeprecated( __METHOD__, '1.24' );
- return self::normalizeLinkUrl( $url );
- }
-
/**
* Replace unusual escape codes in a URL with their equivalent characters
*
continue;
}
- $origLink = $m[1];
+ $origLink = ltrim( $m[1], ' ' );
# Don't allow internal links to pages containing
# PROTO: where PROTO is a valid URL protocol; these
. ' called while parsing (no title set)' );
}
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
/**
* Some of these require message or data lookups and can be
* expensive to check many times.
*/
- if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$this, &$this->mVarCache ] ) ) {
+ if ( Hooks::run( 'ParserGetVariableValueVarCache', [ &$parser, &$this->mVarCache ] ) ) {
if ( isset( $this->mVarCache[$index] ) ) {
return $this->mVarCache[$index];
}
}
$ts = wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() );
- Hooks::run( 'ParserGetVariableValueTs', [ &$this, &$ts ] );
+ Hooks::run( 'ParserGetVariableValueTs', [ &$parser, &$ts ] );
$pageLang = $this->getFunctionLang();
case 'contentlanguage':
global $wgLanguageCode;
return $wgLanguageCode;
+ case 'pagelanguage':
+ $value = $pageLang->getCode();
+ break;
case 'cascadingsources':
$value = CoreParserFunctions::cascadingsources( $this );
break;
$ret = null;
Hooks::run(
'ParserGetVariableValueSwitch',
- [ &$this, &$this->mVarCache, &$index, &$ret, &$frame ]
+ [ &$parser, &$this->mVarCache, &$index, &$ret, &$frame ]
);
return $ret;
throw new MWException( "Tag hook for $function is not callable\n" );
}
- $allArgs = [ &$this ];
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+
+ $allArgs = [ &$parser ];
if ( $flags & self::SFH_OBJECT_ARGS ) {
# Convert arguments to PPNodes and collect for appending to $allArgs
$funcArgs = [];
throw new MWException( "Tag hook for $name is not callable\n" );
}
- $output = call_user_func_array( $callback, [ &$this, $frame, $content, $attributes ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ $output = call_user_func_array( $callback, [ &$parser, $frame, $content, $attributes ] );
} else {
$output = '<span class="error">Invalid tag extension name: ' .
htmlspecialchars( $name ) . '</span>';
}
$ig->setAdditionalOptions( $params );
- Hooks::run( 'BeforeParserrenderImageGallery', [ &$this, &$ig ] );
+ // Avoid PHP 7.1 warning from passing $this by reference
+ $parser = $this;
+ Hooks::run( 'BeforeParserrenderImageGallery', [ &$parser, &$ig ] );
$lines = StringUtils::explode( "\n", $text );
foreach ( $lines as $line ) {