|| isset( $this->mDoubleUnderscores['notitleconvert'] )
|| $this->mOutput->getDisplayTitle() !== false )
) {
- $convruletitle = $this->getConverterLanguage()->getConvRuleTitle();
+ $convruletitle = $this->getTargetLanguage()->getConvRuleTitle();
if ( $convruletitle ) {
$this->mOutput->setTitleText( $convruletitle );
} else {
- $titleText = $this->getConverterLanguage()->convertTitle( $title );
+ $titleText = $this->getTargetLanguage()->convertTitle( $title );
$this->mOutput->setTitleText( $titleText );
}
}
// Add on template profiling data in human/machine readable way
$dataByFunc = $this->mProfiler->getFunctionStats();
uasort( $dataByFunc, function ( $a, $b ) {
- return $a['real'] < $b['real']; // descending order
+ return $b['real'] <=> $a['real']; // descending order
} );
$profileReport = [];
foreach ( array_slice( $dataByFunc, 0, 10 ) as $item ) {
/**
* Get the language object for language conversion
+ * @deprecated since 1.32, just use getTargetLanguage()
* @return Language|null
*/
public function getConverterLanguage() {
# The position of the convert() call should not be changed. it
# assumes that the links are all replaced and the only thing left
# is the <nowiki> mark.
- $text = $this->getConverterLanguage()->convert( $text );
+ $text = $this->getTargetLanguage()->convert( $text );
}
}
if ( $text === false ) {
# Not an image, make a link
$text = Linker::makeExternalLink( $url,
- $this->getConverterLanguage()->markNoConversion( $url, true ),
+ $this->getTargetLanguage()->getConverter()->markNoConversion( $url ),
true, 'free',
$this->getExternalLinkAttribs( $url ), $this->mTitle );
# Register it in the output object...
list( $dtrail, $trail ) = Linker::splitTrail( $trail );
}
- $text = $this->getConverterLanguage()->markNoConversion( $text );
+ // Excluding protocol-relative URLs may avoid many false positives.
+ if ( preg_match( '/^(?:' . wfUrlProtocolsWithoutProtRel() . ')/', $text ) ) {
+ $text = $this->getTargetLanguage()->getConverter()->markNoConversion( $text );
+ }
$url = Sanitizer::cleanUrl( $url );
}
$sortkey = Sanitizer::decodeCharReferences( $sortkey );
$sortkey = str_replace( "\n", '', $sortkey );
- $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey );
+ $sortkey = $this->getTargetLanguage()->convertCategoryKey( $sortkey );
$this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
continue;
$this->mOutput->setFlag( 'vary-revision' );
wfDebug( __METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n" );
}
- $value = $pageid ? $pageid : null;
+ $value = $pageid ?: null;
break;
case 'revisionid':
# Let the edit saving system know we should parse the page
for ( $i = 0; $i < $argsLength; $i++ ) {
$funcArgs[] = $args->item( $i );
}
- try {
- $result = $this->callParserFunction( $frame, $func, $funcArgs );
- } catch ( Exception $ex ) {
- throw $ex;
- }
+
+ $result = $this->callParserFunction( $frame, $func, $funcArgs );
// Extract any forwarded flags
if ( isset( $result['title'] ) ) {
if ( $title ) {
$titleText = $title->getPrefixedText();
# Check for language variants if the template is not found
- if ( $this->getConverterLanguage()->hasVariants() && $title->getArticleID() == 0 ) {
- $this->getConverterLanguage()->findVariantLink( $part1, $title, true );
+ if ( $this->getTargetLanguage()->hasVariants() && $title->getArticleID() == 0 ) {
+ $this->getTargetLanguage()->findVariantLink( $part1, $title, true );
}
# Do recursion depth check
$limit = $this->mOptions->getMaxTemplateDepth();
}
}
- $result = call_user_func_array( $callback, $allArgs );
+ $result = $callback( ...$allArgs );
# The interface for function hooks allows them to return a wikitext
# string or an array containing the string and any flags. This mungs
if ( is_string( $stuff['text'] ) ) {
$text = strtr( $text, "\x7f", "?" );
}
- $finalTitle = isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title;
+ $finalTitle = $stuff['finalTitle'] ?? $title;
if ( isset( $stuff['deps'] ) ) {
foreach ( $stuff['deps'] as $dep ) {
$this->mOutput->addTemplate( $dep['title'], $dep['page_id'], $dep['rev_id'] );
* @param Title $title
* @param array $options Array of options to RepoGroup::findFile
* @return File|bool
+ * @deprecated since 1.32, use fetchFileAndTitle instead
*/
public function fetchFile( $title, $options = [] ) {
+ wfDeprecated( __METHOD__, '1.32' );
return $this->fetchFileAndTitle( $title, $options )[0];
}
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setHook('$tag', ...) call" );
}
- $oldVal = isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null;
+ $oldVal = $this->mTagHooks[$tag] ?? null;
$this->mTagHooks[$tag] = $callback;
if ( !in_array( $tag, $this->mStripList ) ) {
$this->mStripList[] = $tag;
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setTransparentHook('$tag', ...) call" );
}
- $oldVal = isset( $this->mTransparentTagHooks[$tag] ) ? $this->mTransparentTagHooks[$tag] : null;
+ $oldVal = $this->mTransparentTagHooks[$tag] ?? null;
$this->mTransparentTagHooks[$tag] = $callback;
return $oldVal;
if ( preg_match( '/[<>\r\n]/', $tag, $m ) ) {
throw new MWException( "Invalid character {$m[0]} in setFunctionTagHook('$tag', ...) call" );
}
- $old = isset( $this->mFunctionTagHooks[$tag] ) ?
- $this->mFunctionTagHooks[$tag] : null;
+ $old = $this->mFunctionTagHooks[$tag] ?? null;
$this->mFunctionTagHooks[$tag] = [ $callback, $flags ];
if ( !in_array( $tag, $this->mStripList ) ) {
Hooks::run( 'ParserMakeImageParams', [ $title, $file, &$params, $this ] );
# Linker does the rest
- $time = isset( $options['time'] ) ? $options['time'] : false;
+ $time = $options['time'] ?? false;
$ret = Linker::makeImageLink( $this, $title, $file, $params['frame'], $params['handler'],
$time, $descQuery, $this->mOptions->getThumbSize() );