jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/394755 )
Change subject: Handle integers passed as link text ...................................................................... Handle integers passed as link text This issue occurs on the Special:Log page when viewing the patrol log in MW 1.30+. This also fixes a bug introduced in I2e5dfb586e5169dd7c3b0c4ffdca84974c2163c8 that causes self links to be wrapped in HtmlArmor. And, unnecessary hook return statements are removed. Upgraded manifest version. Requires MediaWiki 1.29+. Bug: T181669 Change-Id: I997224257dc62284469168c9752f72367d0496e1 --- M extension.json M includes/DisplayTitleHooks.php 2 files changed, 17 insertions(+), 24 deletions(-) Approvals: Kghbln: Looks good to me, but someone else must approve Legoktm: Looks good to me, approved jenkins-bot: Verified Samwilson: Looks good to me, but someone else must approve diff --git a/extension.json b/extension.json index 3775ed5..257ae37 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "DisplayTitle", - "version": "1.5.3", + "version": "2.0.0", "author": [ "[https://www.mediawiki.org/wiki/User:Cindy.cicalese Cindy Cicalese]", "[https://www.semantic-mediawiki.org/wiki/User:Oetterer Tobias Oetterer]" @@ -31,7 +31,9 @@ "SelfLinkBegin": "DisplayTitleHooks::onSelfLinkBegin" }, "config": { - "DisplayTitleHideSubtitle": false + "DisplayTitleHideSubtitle": { + "value": false + } }, - "manifest_version": 1 + "manifest_version": 2 } diff --git a/includes/DisplayTitleHooks.php b/includes/DisplayTitleHooks.php index c03add4..975814c 100644 --- a/includes/DisplayTitleHooks.php +++ b/includes/DisplayTitleHooks.php @@ -10,12 +10,10 @@ * See https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit * @since 1.0 * @param Parser &$parser the Parser object - * @return bool continue checking hooks */ public static function onParserFirstCallInit( &$parser ) { $parser->setFunctionHook( 'getdisplaytitle', 'DisplayTitleHooks::getdisplaytitleParserFunction' ); - return true; } /** @@ -69,13 +67,12 @@ * @param array &$extraAttribs the HTML attributes that the <a> tag should have * @param string &$query the query string to add to the generated URL * @param string &$ret the value to return if the hook returns false - * @return bool continue checking hooks */ public static function onHtmlPageLinkRendererBegin( LinkRenderer $linkRenderer, LinkTarget $target, &$text, &$extraAttribs, &$query, &$ret ) { $title = Title::newFromLinkTarget( $target ); - return self::handleLink( $title, $text ); + self::handleLink( $title, $text, true ); } /** @@ -89,11 +86,10 @@ * @param string &$trail Text after link * @param string &$prefix Text before link * @param string &$ret the value to return if the hook returns false - * @return bool continue checking hooks */ public static function onSelfLinkBegin( Title $nt, &$html, &$trail, &$prefix, &$ret ) { - return self::handleLink( $nt, $html ); + self::handleLink( $nt, $html, false ); } /** @@ -107,36 +103,37 @@ * @since 1.3 * @param Title $target the Title object that the link is pointing to * @param string|HtmlArmor &$html the HTML of the link text - * @return bool continue checking hooks + * @param boolean $wrap whether to wrap result in HtmlArmor */ - private static function handleLink( Title $target, &$html ) { + private static function handleLink( Title $target, &$html, $wrap ) { if ( isset( $html ) ) { $title = null; $text = null; if ( is_string( $html ) ) { $text = $html; - } elseif ( get_class( $html ) == 'HtmlArmor' ) { + } elseif ( is_integer( $html ) ) { + $text = (string)$html; + } elseif ( $html instanceof HtmlArmor ) { $text = HtmlArmor::getHtml( $html ); } - if ( $text !== null ) { + if ( !is_null( $text ) ) { $title = Title::newFromText( $text ); if ( !is_null( $title ) ) { if ( $target->getSubjectNsText() === '' ) { if ( $text === $target->getText() ) { - self::getDisplayTitle( $target, $html, true ); + self::getDisplayTitle( $target, $html, $wrap ); } } else { if ( $title->getText() === $target->getText() && $title->getSubjectNsText() === $target->getSubjectNsText() ) { - self::getDisplayTitle( $target, $html, true ); + self::getDisplayTitle( $target, $html, $wrap ); } } } } } else { - self::getDisplayTitle( $target, $html, true ); + self::getDisplayTitle( $target, $html, $wrap ); } - return true; } /** @@ -147,11 +144,10 @@ * @since 1.0 * @param OutputPage &$out the OutputPage object * @param Skin &$sk the Skin object - * @return bool continue checking hooks */ public static function onBeforePageDisplay( OutputPage &$out, Skin &$sk ) { if ( $GLOBALS['wgDisplayTitleHideSubtitle'] ) { - return true; + return; } $title = $out->getTitle(); if ( !$title->isTalkPage() ) { @@ -169,7 +165,6 @@ } $out->setSubtitle( $subtitle ); } - return true; } /** @@ -181,7 +176,6 @@ * @param Parser &$parser the Parser object * @param string &$text the text * @param StripState &$strip_state the strip state - * @return bool continue checking hooks */ public static function onParserBeforeStrip( Parser &$parser, &$text, &$strip_state ) { @@ -194,7 +188,6 @@ $parser->mOutput->setTitleText( $displaytitle ); } } - return true; } /** @@ -205,13 +198,11 @@ * @since 1.2 * @param string $engine engine in use * @param array &$extraLibraries list of registered libraries - * @return bool continue checking hooks */ public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ) { if ( $engine === 'lua' ) { $extraLibraries['mw.ext.displaytitle'] = 'DisplayTitleLuaLibrary'; } - return true; } /** -- To view, visit https://gerrit.wikimedia.org/r/394755 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I997224257dc62284469168c9752f72367d0496e1 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/DisplayTitle Gerrit-Branch: master Gerrit-Owner: Cicalese <ccical...@wikimedia.org> Gerrit-Reviewer: Cicalese <ccical...@wikimedia.org> Gerrit-Reviewer: Kghbln <mediaw...@kghoffmeyer.de> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Samwilson <s...@samwilson.id.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits