$limitReport = str_replace( [ '-', '&' ], [ '‐', '&' ], $limitReport );
$text .= "\n<!-- \n$limitReport-->\n";
- // Add on template profiling data
+ // 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
} );
- $profileReport = "Transclusion expansion time report (%,ms,calls,template)\n";
+ $profileReport = [];
foreach ( array_slice( $dataByFunc, 0, 10 ) as $item ) {
- $profileReport .= sprintf( "%6.2f%% %8.3f %6d - %s\n",
+ $profileReport[] = sprintf( "%6.2f%% %8.3f %6d %s",
$item['%real'], $item['real'], $item['calls'],
htmlspecialchars( $item['name'] ) );
}
- $text .= "\n<!-- \n$profileReport-->\n";
+ $text .= "<!--\nTransclusion expansion time report (%,ms,calls,template)\n";
+ $text .= implode( "\n", $profileReport ) . "\n-->\n";
+
+ $this->mOutput->setLimitReportData( 'limitreport-timingprofile', $profileReport );
+
+ // Add other cache related metadata
+ if ( $wgShowHostnames ) {
+ $this->mOutput->setLimitReportData( 'cachereport-origin', wfHostname() );
+ }
+ $this->mOutput->setLimitReportData( 'cachereport-timestamp',
+ $this->mOutput->getCacheTime() );
+ $this->mOutput->setLimitReportData( 'cachereport-ttl',
+ $this->mOutput->getCacheExpiry() );
+ $this->mOutput->setLimitReportData( 'cachereport-transientcontent',
+ $this->mOutput->hasDynamicContent() );
if ( $this->mGeneratedPPNodeCount > $this->mOptions->getMaxGeneratedPPNodeCount() / 10 ) {
wfDebugLog( 'generated-pp-node-count', $this->mGeneratedPPNodeCount . ' ' .
# T2553: Note that a '|' inside an invalid link should not
# be mistaken as delimiting cell parameters
- if ( strpos( $cell_data[0], '[[' ) !== false ) {
+ # Bug T153140: Neither should language converter markup.
+ if ( preg_match( '/\[\[|-\{/', $cell_data[0] ) === 1 ) {
$cell = "{$previous}<{$last_tag}>{$cell}";
} elseif ( count( $cell_data ) == 1 ) {
$cell = "{$previous}<{$last_tag}>{$cell_data[0]}";
case 'contentlanguage':
global $wgLanguageCode;
return $wgLanguageCode;
+ case 'pagelanguage':
+ $value = $pageLang->getCode();
+ break;
case 'cascadingsources':
$value = CoreParserFunctions::cascadingsources( $this );
break;
$descQuery = false;
Hooks::run( 'BeforeParserFetchFileAndTitle',
[ $this, $title, &$options, &$descQuery ] );
- # Don't register it now, as ImageGallery does that later.
+ # Don't register it now, as TraditionalImageGallery does that later.
$file = $this->fetchFileNoRegister( $title, $options );
$handler = $file ? $file->getHandler() : false;
// FIXME: Doing recursiveTagParse at this stage, and the trim before
// splitting on '|' is a bit odd, and different from makeImage.
$matches[3] = $this->recursiveTagParse( trim( $matches[3] ) );
- $parameterMatches = StringUtils::explode( '|', $matches[3] );
+ // Protect LanguageConverter markup
+ $parameterMatches = StringUtils::delimiterExplode(
+ '-{', '}-', '|', $matches[3], true /* nested */
+ );
foreach ( $parameterMatches as $parameterMatch ) {
list( $magicName, $match ) = $mwArray->matchVariableStartToEnd( $parameterMatch );
$addr = self::EXT_LINK_ADDR;
$prots = $this->mUrlProtocols;
// check to see if link matches an absolute url, if not then it must be a wiki link.
+ if ( preg_match( '/^-{R|(.*)}-$/', $linkValue ) ) {
+ // Result of LanguageConverter::markNoConversion
+ // invoked on an external link.
+ $linkValue = substr( $linkValue, 4, -2 );
+ }
if ( preg_match( "/^($prots)$addr$chars*$/u", $linkValue ) ) {
$link = $linkValue;
} else {
# * bottom
# * text-bottom
- $parts = StringUtils::explode( "|", $options );
+ # Protect LanguageConverter markup when splitting into parts
+ $parts = StringUtils::delimiterExplode(
+ '-{', '}-', '|', $options, true /* allow nesting */
+ );
# Give extensions a chance to select the file revision for us
$options = [];
case 'framed':
case 'thumbnail':
// use first appearing option, discard others.
- $validated = ! $seenformat;
+ $validated = !$seenformat;
$seenformat = true;
break;
default:
* External callers should use the getSection and replaceSection methods.
*
* @param string $text Page wikitext
- * @param string|number $sectionId A section identifier string of the form:
+ * @param string|int $sectionId A section identifier string of the form:
* "<flag1> - <flag2> - ... - <section number>"
*
* Currently the only recognised flag is "T", which means the target section number
* If a section contains subsections, these are also returned.
*
* @param string $text Text to look in
- * @param string|number $sectionId Section identifier as a number or string
+ * @param string|int $sectionId Section identifier as a number or string
* (e.g. 0, 1 or 'T-1').
* @param string $defaultText Default to return if section is not found
*
* section does not exist, $oldtext is returned unchanged.
*
* @param string $oldText Former text of the article
- * @param string|number $sectionId Section identifier as a number or string
+ * @param string|int $sectionId Section identifier as a number or string
* (e.g. 0, 1 or 'T-1').
* @param string $newText Replacing text
*