The following public methods were renamed and made private; the old name
is hard-deprecated and calls the new renamed private method:
Parser::doMagicLinks() => handleMagicLinks()
Parser::doDoubleUnderscore() => handleMagicLinks()
Parser::doHeadings() => handleHeadings()
Parser::doAllQuotes() => handleAllQuotes()
Parser::replaceExternalLinks() => handleExternalLinks()
Parser::replaceInternalLinks() => handleInternalLinks()
Parser::replaceInternalLinks2() => handleInternalLinks2()
Parser::getVariableValue() => expandMagicVariable()
Parser::initialiseVariables() => initializeVariables()
Parser::formatHeadings() => finalizeHeadings()
Parser::test{Pst,Preprocess,Srvus}() => fuzzTest{Pst,Preprocess,Srvus}()
Additionally, the following methods are not used externally, but are
used outside the Parser class by core code. They have been marked
@internal:
Parser::doQuotes() (used by {{#displaytitle}}),
Parser::getExternalLink{Rel,Attribs}() (used by Linker),
Parser::normalizeLinkUrl() (used by Special:LinkSearch and elsewhere).
Parser::{brace,arg,extension}Substitution() (used by PPFrame)
Code search query:
https://codesearch.wmflabs.org/deployed/?q=do%28MagicLinks%7CDoubleUnderscore%7CHeadings%7CAllQuotes%29%7Creplace%28ExternalLinks%7CInternalLinks%28%7C2%29%29%7CgetVariableValue%7CinitialiseVariables%7CformatHeadings%7Ctest%28Pst%7CPreprocess%7CSrvus%29%7CdoQuotes%7CgetExternalLink%28Rel%7CAttribs%29%7CnormalizeLinkUrl%7C%28brace%2Carg%2Cextension%29Substitution&i=nope&files=&repos=
Bug: T236810
Change-Id: I19a43ffc5dcfdd2981b51079c33422c964acb076
* 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.
* 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.
+* A number of public methods of Parser were exposed only for historical
+ reasons and have been deprecated: doMagicLinks, doDoubleUnderscore,
+ doHeadings, doAllQuotes, replaceExternalLinks, replaceInternalLinks,
+ replaceInternalLinks2, getVariableValue, initialiseVariables, formatHeadings,
+ testPst, testPreprocess, testSrvus.
=== Other changes in 1.34 ===
* Added option to specify "Various authors" as author in extension credits using
=== Other changes in 1.34 ===
* Added option to specify "Various authors" as author in extension credits using
*/
public $mFirstCall = true;
*/
public $mFirstCall = true;
- # Initialised by initialiseVariables()
+ # Initialised by initializeVariables()
/**
* @var MagicWordArray
/**
* @var MagicWordArray
CoreParserFunctions::register( $this );
CoreTagHooks::register( $this );
CoreParserFunctions::register( $this );
CoreTagHooks::register( $this );
- $this->initialiseVariables();
+ $this->initializeVariables();
// Avoid PHP 7.1 warning from passing $this by reference
$parser = $this;
// Avoid PHP 7.1 warning from passing $this by reference
$parser = $this;
- * parse the wiki syntax used to render tables
+ * Parse the wiki syntax used to render tables.
*
* @private
* @param string $text
* @return string
*
* @private
* @param string $text
* @return string
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function doTableStuff( $text ) {
*/
public function doTableStuff( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleTables( $text );
+ }
+
+ /**
+ * Parse the wiki syntax used to render tables.
+ *
+ * @param string $text
+ * @return string
+ */
+ private function handleTables( $text ) {
$lines = StringUtils::explode( "\n", $text );
$out = '';
$td_history = []; # Is currently a td tag open?
$lines = StringUtils::explode( "\n", $text );
$out = '';
$td_history = []; # Is currently a td tag open?
# properly; putting them before other transformations should keep
# exciting things like link expansions from showing up in surprising
# places.
# properly; putting them before other transformations should keep
# exciting things like link expansions from showing up in surprising
# places.
- $text = $this->doTableStuff( $text );
+ $text = $this->handleTables( $text );
$text = preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text );
$text = preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text );
- $text = $this->doDoubleUnderscore( $text );
+ $text = $this->handleDoubleUnderscore( $text );
- $text = $this->doHeadings( $text );
- $text = $this->replaceInternalLinks( $text );
- $text = $this->doAllQuotes( $text );
- $text = $this->replaceExternalLinks( $text );
+ $text = $this->handleHeadings( $text );
+ $text = $this->handleInternalLinks( $text );
+ $text = $this->handleAllQuotes( $text );
+ $text = $this->handleExternalLinks( $text );
- # replaceInternalLinks may sometimes leave behind
- # absolute URLs, which have to be masked to hide them from replaceExternalLinks
+ # handleInternalLinks may sometimes leave behind
+ # absolute URLs, which have to be masked to hide them from handleExternalLinks
$text = str_replace( self::MARKER_PREFIX . 'NOPARSE', '', $text );
$text = str_replace( self::MARKER_PREFIX . 'NOPARSE', '', $text );
- $text = $this->doMagicLinks( $text );
- $text = $this->formatHeadings( $text, $origText, $isMain );
+ $text = $this->handleMagicLinks( $text );
+ $text = $this->finalizeHeadings( $text, $origText, $isMain );
+ * @param string $text
+ * @return string
+ * @deprecated since 1.34; should not be used outside parser class.
+ */
+ public function doMagicLinks( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleMagicLinks( $text );
+ }
+
+ /**
+ * Replace special strings like "ISBN xxx" and "RFC xxx" with
+ * magic external links.
+ *
+ * DML
*
* @param string $text
*
* @return string
*/
*
* @param string $text
*
* @return string
*/
- public function doMagicLinks( $text ) {
+ private function handleMagicLinks( $text ) {
$prots = wfUrlProtocolsWithoutProtRel();
$urlChar = self::EXT_LINK_URL_CLASS;
$addr = self::EXT_LINK_ADDR;
$prots = wfUrlProtocolsWithoutProtRel();
$urlChar = self::EXT_LINK_URL_CLASS;
$addr = self::EXT_LINK_ADDR;
- * Parse headers and return html
+ * Parse headers and return html.
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function doHeadings( $text ) {
*/
public function doHeadings( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleHeadings( $text );
+ }
+
+ /**
+ * Parse headers and return html
+ *
+ * @param string $text
+ * @return string
+ */
+ private function handleHeadings( $text ) {
for ( $i = 6; $i >= 1; --$i ) {
$h = str_repeat( '=', $i );
// Trim non-newline whitespace from headings
for ( $i = 6; $i >= 1; --$i ) {
$h = str_repeat( '=', $i );
// Trim non-newline whitespace from headings
* @param string $text
*
* @return string The altered text
* @param string $text
*
* @return string The altered text
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function doAllQuotes( $text ) {
*/
public function doAllQuotes( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleAllQuotes( $text );
+ }
+
+ /**
+ * Replace single quotes with HTML markup
+ *
+ * @param string $text
+ *
+ * @return string The altered text
+ */
+ private function handleAllQuotes( $text ) {
$outtext = '';
$lines = StringUtils::explode( "\n", $text );
foreach ( $lines as $line ) {
$outtext = '';
$lines = StringUtils::explode( "\n", $text );
foreach ( $lines as $line ) {
* @param string $text
*
* @return string
* @param string $text
*
* @return string
*/
public function doQuotes( $text ) {
$arr = preg_split( "/(''+)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE );
*/
public function doQuotes( $text ) {
$arr = preg_split( "/(''+)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE );
* @return string
*/
public function replaceExternalLinks( $text ) {
* @return string
*/
public function replaceExternalLinks( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleExternalLinks( $text );
+ }
+
+ /**
+ * Replace external links (REL)
+ *
+ * Note: this is all very hackish and the order of execution matters a lot.
+ * Make sure to run tests/parser/parserTests.php if you change this code.
+ *
+ * @param string $text
+ * @throws MWException
+ * @return string
+ */
+ private function handleExternalLinks( $text ) {
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
// @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3161
if ( $bits === false ) {
$bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE );
// @phan-suppress-next-line PhanTypeComparisonFromArray See phan issue #3161
if ( $bits === false ) {
* Get the rel attribute for a particular external link.
*
* @since 1.21
* Get the rel attribute for a particular external link.
*
* @since 1.21
* @param string|bool $url Optional URL, to extract the domain from for rel =>
* nofollow if appropriate
* @param LinkTarget|null $title Optional LinkTarget, for wgNoFollowNsExceptions lookups
* @param string|bool $url Optional URL, to extract the domain from for rel =>
* nofollow if appropriate
* @param LinkTarget|null $title Optional LinkTarget, for wgNoFollowNsExceptions lookups
* (depending on configuration, namespace, and the URL's domain) and/or a
* target attribute (depending on configuration).
*
* (depending on configuration, namespace, and the URL's domain) and/or a
* target attribute (depending on configuration).
*
* @param string $url URL to extract the domain from for rel =>
* nofollow if appropriate
* @return array Associative array of HTML attributes
* @param string $url URL to extract the domain from for rel =>
* nofollow if appropriate
* @return array Associative array of HTML attributes
* This generally follows the syntax defined in RFC 3986, with special
* consideration for HTTP query strings.
*
* This generally follows the syntax defined in RFC 3986, with special
* consideration for HTTP query strings.
*
* @param string $url
* @return string
*/
* @param string $url
* @return string
*/
/**
* Process [[ ]] wikilinks
*
/**
* Process [[ ]] wikilinks
*
*
* @return string Processed text
*
* @private
*
* @return string Processed text
*
* @private
+ * @deprecated since 1.34; should not be used outside parser class.
- public function replaceInternalLinks( $s ) {
- $this->mLinkHolders->merge( $this->replaceInternalLinks2( $s ) );
- return $s;
+ public function replaceInternalLinks( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleInternalLinks( $text );
+ }
+
+ /**
+ * Process [[ ]] wikilinks
+ *
+ * @param string $text
+ *
+ * @return string Processed text
+ */
+ private function handleInternalLinks( $text ) {
+ $this->mLinkHolders->merge( $this->handleInternalLinks2( $text ) );
+ return $text;
}
/**
* Process [[ ]] wikilinks (RIL)
}
/**
* Process [[ ]] wikilinks (RIL)
* @throws MWException
* @return LinkHolderArray
*
* @private
* @throws MWException
* @return LinkHolderArray
*
* @private
+ * @deprecated since 1.34; should not be used outside parser class.
- public function replaceInternalLinks2( &$s ) {
+ public function replaceInternalLinks2( &$text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleInternalLinks2( $text );
+ }
+
+ /**
+ * Process [[ ]] wikilinks (RIL)
+ * @param string &$s
+ * @throws MWException
+ * @return LinkHolderArray
+ */
+ private function handleInternalLinks2( &$s ) {
static $tc = false, $e1, $e1_img;
# the % is needed to support urlencoded titles as well
if ( !$tc ) {
static $tc = false, $e1, $e1_img;
# the % is needed to support urlencoded titles as well
if ( !$tc ) {
&& substr( $m[3], 0, 1 ) === ']'
&& strpos( $text, '[' ) !== false
) {
&& substr( $m[3], 0, 1 ) === ']'
&& strpos( $text, '[' ) !== false
) {
- $text .= ']'; # so that replaceExternalLinks($text) works later
+ $text .= ']'; # so that handleExternalLinks($text) works later
$m[3] = substr( $m[3], 1 );
}
# fix up urlencoded title texts
$m[3] = substr( $m[3], 1 );
}
# fix up urlencoded title texts
if ( !$found ) {
# we couldn't find the end of this imageLink, so output it raw
# but don't ignore what might be perfectly normal links in the text we've examined
if ( !$found ) {
# we couldn't find the end of this imageLink, so output it raw
# but don't ignore what might be perfectly normal links in the text we've examined
- $holders->merge( $this->replaceInternalLinks2( $text ) );
+ $holders->merge( $this->handleInternalLinks2( $text ) );
$s .= "{$prefix}[[$link|$text";
# note: no $trail, because without an end, there *is* no trail
continue;
$s .= "{$prefix}[[$link|$text";
# note: no $trail, because without an end, there *is* no trail
continue;
# recursively parse links inside the image caption
# actually, this will parse them in any other parameters, too,
# but it might be hard to fix that, and it doesn't matter ATM
# recursively parse links inside the image caption
# actually, this will parse them in any other parameters, too,
# but it might be hard to fix that, and it doesn't matter ATM
- $text = $this->replaceExternalLinks( $text );
- $holders->merge( $this->replaceInternalLinks2( $text ) );
+ $text = $this->handleExternalLinks( $text );
+ $holders->merge( $this->handleInternalLinks2( $text ) );
- # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
+ # cloak any absolute URLs inside the image markup, so handleExternalLinks() won't touch them
$s .= $prefix . $this->armorLinks(
$this->makeImage( $nt, $text, $holders ) ) . $trail;
continue;
$s .= $prefix . $this->armorLinks(
$this->makeImage( $nt, $text, $holders ) ) . $trail;
continue;
[ $this, $nt, &$options, &$descQuery ] );
# Fetch and register the file (file title may be different via hooks)
list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $options );
[ $this, $nt, &$options, &$descQuery ] );
# Fetch and register the file (file title may be different via hooks)
list( $file, $nt ) = $this->fetchFileAndTitle( $nt, $options );
- # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
+ # Cloak with NOPARSE to avoid replacement in handleExternalLinks
$s .= $prefix . $this->armorLinks(
Linker::makeMediaLinkFile( $nt, $file, $text ) ) . $trail;
continue;
$s .= $prefix . $this->armorLinks(
Linker::makeMediaLinkFile( $nt, $file, $text ) ) . $trail;
continue;
*
* @throws MWException
* @return string
*
* @throws MWException
* @return string
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function getVariableValue( $index, $frame = false ) {
*/
public function getVariableValue( $index, $frame = false ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->expandMagicVariable( $index, $frame );
+ }
+
+ /**
+ * Return value of a magic variable (like PAGENAME)
+ *
+ * @param string $index Magic variable identifier as mapped in MagicWordFactory::$mVariableIDs
+ * @param bool|PPFrame $frame
+ *
+ * @throws MWException
+ * @return string
+ */
+ private function expandMagicVariable( $index, $frame = false ) {
+ // XXX This function should be moved out of Parser class for
+ // reuse by Parsoid/etc.
if ( is_null( $this->mTitle ) ) {
// If no title set, bad things are going to happen
// later. Title should always be set since this
if ( is_null( $this->mTitle ) ) {
// If no title set, bad things are going to happen
// later. Title should always be set since this
* initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
*
* @private
* initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
*
* @private
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function initialiseVariables() {
*/
public function initialiseVariables() {
+ wfDeprecated( __METHOD__, '1.34' );
+ $this->initializeVariables();
+ }
+
+ /**
+ * Initialize the magic variables (like CURRENTMONTHNAME) and
+ * substitution modifiers.
+ */
+ private function initializeVariables() {
$variableIDs = $this->magicWordFactory->getVariableIDs();
$substIDs = $this->magicWordFactory->getSubstIDs();
$variableIDs = $this->magicWordFactory->getVariableIDs();
$substIDs = $this->magicWordFactory->getSubstIDs();
* @param PPFrame $frame The current frame, contains template arguments
* @throws Exception
* @return string|array The text of the template
* @param PPFrame $frame The current frame, contains template arguments
* @throws Exception
* @return string|array The text of the template
*/
public function braceSubstitution( $piece, $frame ) {
// Flags
*/
public function braceSubstitution( $piece, $frame ) {
// Flags
if ( !$found && $args->getLength() == 0 ) {
$id = $this->mVariables->matchStartToEnd( $part1 );
if ( $id !== false ) {
if ( !$found && $args->getLength() == 0 ) {
$id = $this->mVariables->matchStartToEnd( $part1 );
if ( $id !== false ) {
- $text = $this->getVariableValue( $id, $frame );
+ $text = $this->expandMagicVariable( $id, $frame );
if ( $this->magicWordFactory->getCacheTTL( $id ) > -1 ) {
$this->mOutput->updateCacheExpiry(
$this->magicWordFactory->getCacheTTL( $id ) );
if ( $this->magicWordFactory->getCacheTTL( $id ) > -1 ) {
$this->mOutput->updateCacheExpiry(
$this->magicWordFactory->getCacheTTL( $id ) );
/**
* Triple brace replacement -- used for template arguments
/**
* Triple brace replacement -- used for template arguments
*
* @param array $piece
* @param PPFrame $frame
*
* @param array $piece
* @param PPFrame $frame
*
* @throws MWException
* @return string
*
* @throws MWException
* @return string
*/
public function extensionSubstitution( $params, $frame ) {
static $errorStr = '<span class="error">';
*/
public function extensionSubstitution( $params, $frame ) {
static $errorStr = '<span class="error">';
* Fills $this->mDoubleUnderscores, returns the modified text
*
* @param string $text
* Fills $this->mDoubleUnderscores, returns the modified text
*
* @param string $text
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function doDoubleUnderscore( $text ) {
*/
public function doDoubleUnderscore( $text ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->handleDoubleUnderscore( $text );
+ }
+
+ /**
+ * Strip double-underscore items like __NOGALLERY__ and __NOTOC__
+ * Fills $this->mDoubleUnderscores, returns the modified text
+ *
+ * @param string $text
+ * @return string
+ */
+ private function handleDoubleUnderscore( $text ) {
# The position of __TOC__ needs to be recorded
$mw = $this->magicWordFactory->get( 'toc' );
if ( $mw->match( $text ) ) {
# The position of __TOC__ needs to be recorded
$mw = $this->magicWordFactory->get( 'toc' );
if ( $mw->match( $text ) ) {
* @param bool $isMain
* @return mixed|string
* @private
* @param bool $isMain
* @return mixed|string
* @private
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function formatHeadings( $text, $origText, $isMain = true ) {
*/
public function formatHeadings( $text, $origText, $isMain = true ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->finalizeHeadings( $text, $origText, $isMain );
+ }
+
+ /**
+ * This function accomplishes several tasks:
+ * 1) Auto-number headings if that option is enabled
+ * 2) Add an [edit] link to sections for users who have enabled the option and can edit the page
+ * 3) Add a Table of contents on the top for users who have enabled the option
+ * 4) Auto-anchor headings
+ *
+ * It loops through all headlines, collects the necessary data, then splits up the
+ * string and re-inserts the newly formatted headlines.
+ *
+ * @param string $text
+ * @param string $origText Original, untouched wikitext
+ * @param bool $isMain
+ * @return mixed|string
+ */
+ private function finalizeHeadings( $text, $origText, $isMain = true ) {
# Inhibit editsection links if requested in the page
if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
$maybeShowEditLink = false;
# Inhibit editsection links if requested in the page
if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
$maybeShowEditLink = false;
# Get all headlines for numbering them and adding funky stuff like [edit]
# links - this is for later, but we need the number of headlines right now
# Get all headlines for numbering them and adding funky stuff like [edit]
# links - this is for later, but we need the number of headlines right now
- # NOTE: white space in headings have been trimmed in doHeadings. They shouldn't
+ # NOTE: white space in headings have been trimmed in handleHeadings. They shouldn't
# be trimmed here since whitespace in HTML headings is significant.
$matches = [];
$numMatches = preg_match_all(
# be trimmed here since whitespace in HTML headings is significant.
$matches = [];
$numMatches = preg_match_all(
protected function stripAltText( $caption, $holders ) {
# Strip bad stuff out of the title (tooltip). We can't just use
# replaceLinkHoldersText() here, because if this function is called
protected function stripAltText( $caption, $holders ) {
# Strip bad stuff out of the title (tooltip). We can't just use
# replaceLinkHoldersText() here, because if this function is called
- # from replaceInternalLinks2(), mLinkHolders won't be up-to-date.
+ # from handleInternalLinks2(), mLinkHolders won't be up-to-date.
if ( $holders ) {
$tooltip = $holders->replaceText( $caption );
} else {
if ( $holders ) {
$tooltip = $holders->replaceText( $caption );
} else {
* @param int $outputType
*
* @return string
* @param int $outputType
*
* @return string
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function testSrvus( $text, Title $title, ParserOptions $options,
$outputType = self::OT_HTML
*/
public function testSrvus( $text, Title $title, ParserOptions $options,
$outputType = self::OT_HTML
+ ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->fuzzTestSrvus( $text, $title, $options, $outputType );
+ }
+
+ /**
+ * Strip/replaceVariables/unstrip for preprocessor regression testing
+ *
+ * @param string $text
+ * @param Title $title
+ * @param ParserOptions $options
+ * @param int $outputType
+ *
+ * @return string
+ */
+ private function fuzzTestSrvus( $text, Title $title, ParserOptions $options,
+ $outputType = self::OT_HTML
) {
$magicScopeVariable = $this->lock();
$this->startParse( $title, $options, $outputType, true );
) {
$magicScopeVariable = $this->lock();
$this->startParse( $title, $options, $outputType, true );
* @param Title $title
* @param ParserOptions $options
* @return string
* @param Title $title
* @param ParserOptions $options
* @return string
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function testPst( $text, Title $title, ParserOptions $options ) {
*/
public function testPst( $text, Title $title, ParserOptions $options ) {
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->fuzzTestPst( $text, $title, $options );
+ }
+
+ /**
+ * @param string $text
+ * @param Title $title
+ * @param ParserOptions $options
+ * @return string
+ */
+ private function fuzzTestPst( $text, Title $title, ParserOptions $options ) {
return $this->preSaveTransform( $text, $title, $options->getUser(), $options );
}
return $this->preSaveTransform( $text, $title, $options->getUser(), $options );
}
* @param Title $title
* @param ParserOptions $options
* @return string
* @param Title $title
* @param ParserOptions $options
* @return string
+ * @deprecated since 1.34; should not be used outside parser class.
*/
public function testPreprocess( $text, Title $title, ParserOptions $options ) {
*/
public function testPreprocess( $text, Title $title, ParserOptions $options ) {
- return $this->testSrvus( $text, $title, $options, self::OT_PREPROCESS );
+ wfDeprecated( __METHOD__, '1.34' );
+ return $this->fuzzTestPreprocess( $text, $title, $options );
+ }
+
+ /**
+ * @param string $text
+ * @param Title $title
+ * @param ParserOptions $options
+ * @return string
+ */
+ private function fuzzTestPreprocess( $text, Title $title, ParserOptions $options ) {
+ return $this->fuzzTestSrvus( $text, $title, $options, self::OT_PREPROCESS );
use MediaWiki\MediaWikiServices;
use MediaWiki\MediaWikiServices;
+use Wikimedia\TestingAccessWrapper;
+
$optionsWithoutArgs = [ 'verbose' ];
require_once __DIR__ . '/commandLine.inc';
$optionsWithoutArgs = [ 'verbose' ];
require_once __DIR__ . '/commandLine.inc';
public $maxLength = 20;
public $maxTemplates = 5;
// public $outputTypes = [ 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ];
public $maxLength = 20;
public $maxTemplates = 5;
// public $outputTypes = [ 'OT_HTML', 'OT_WIKI', 'OT_PREPROCESS' ];
- public $entryPoints = [ 'testSrvus', 'testPst', 'testPreprocess' ];
+ public $entryPoints = [ 'fuzzTestSrvus', 'fuzzTestPst', 'fuzzTestPreprocess' ];
public $verbose = false;
/**
public $verbose = false;
/**
$options->setTemplateCallback( [ $this, 'templateHook' ] );
$options->setTimestamp( wfTimestampNow() );
$this->output = call_user_func(
$options->setTemplateCallback( [ $this, 'templateHook' ] );
$options->setTimestamp( wfTimestampNow() );
$this->output = call_user_func(
- [ MediaWikiServices::getInstance()->getParser(), $this->entryPoint ],
+ [ TestingAccessWrapper::newFromObject(
+ MediaWikiServices::getInstance()->getParser()
+ ), $this->entryPoint ],
$this->mainText,
$this->title,
$options
$this->mainText,
$this->title,
$options
* Fake constant timestamp to make sure time-related parser
* functions give a persistent value.
*
* Fake constant timestamp to make sure time-related parser
* functions give a persistent value.
*
- * - Parser::getVariableValue (via ParserGetVariableValueTs hook)
+ * - Parser::expandMagicVariable (via ParserGetVariableValueTs hook)
* - Parser::preSaveTransform (via ParserOptions)
*/
private function getFakeTimestamp() {
* - Parser::preSaveTransform (via ParserOptions)
*/
private function getFakeTimestamp() {
-Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
+Interwiki links trounced by handleExternalLinks after early LinkHolderArray expansion
!! options
wgLinkHolderBatchSize=0
!! wikitext
!! options
wgLinkHolderBatchSize=0
!! wikitext
+use Wikimedia\TestingAccessWrapper;
+
- * @covers Parser::getVariableValue
+ * @covers Parser::expandMagicVariable
*/
class MagicVariableTest extends MediaWikiTestCase {
/**
*/
class MagicVariableTest extends MediaWikiTestCase {
/**
$this->assertSame(
$expected,
$this->assertSame(
$expected,
- $this->testParser->getVariableValue( $magic ),
+ TestingAccessWrapper::newFromObject( $this->testParser )->expandMagicVariable( $magic ),