Harej has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/339814 )
Change subject: Resolve redirects on Collaboration Hub ...................................................................... Resolve redirects on Collaboration Hub If an embedded page is a redirect, CollaborationHubContent will resolve the redirect through a new method called redirectProof. Change-Id: I5a251c426c3664c07e2dedea95b010836d070920 --- M includes/content/CollaborationHubContent.php 1 file changed, 22 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CollaborationKit refs/changes/14/339814/1 diff --git a/includes/content/CollaborationHubContent.php b/includes/content/CollaborationHubContent.php index dfb0d33..0f84631 100644 --- a/includes/content/CollaborationHubContent.php +++ b/includes/content/CollaborationHubContent.php @@ -155,6 +155,24 @@ } /** + * Resolves the redirect of a Title if it is in fact a redirect. + * + * Consistent with general MediaWiki behavior, this function does + * not resolve double redirects. + * + * @param Title $title Title which may or may not be a redirect + * @return Title + */ + public function redirectProof( Title $title ) { + if ( $title->isRedirect() ) { + $articleID = $title->getArticleID(); + $wikipage = WikiPage::newFromID( $articleID ); + return $wikipage->getRedirectTarget(); + } + return $title; + } + + /** * @return string */ public function getIntroduction() { @@ -351,7 +369,7 @@ } $membersPageName = $title->getFullText() . '/' . wfMessage( 'collaborationkit-hub-pagetitle-members' )->inContentLanguage()->text(); - $membersTitle = Title::newFromText( $membersPageName ); + $membersTitle = $this->redirectProof( Title::newFromText( $membersPageName ) ); if ( $membersTitle->exists() || $membersContent !== null ) { $membersPageID = $membersTitle->getArticleID(); $output->addJsConfigVars( 'wgCollaborationKitAssociatedMemberList', $membersPageID ); @@ -425,7 +443,7 @@ */ protected function getParsedAnnouncements( Title $title, ParserOptions $options, $announcementsText = null ) { $announcementsSubpageName = wfMessage( 'collaborationkit-hub-pagetitle-announcements' )->inContentLanguage()->text(); - $announcementsTitle = Title::newFromText( $title->getFullText() . '/' . $announcementsSubpageName ); + $announcementsTitle = $this->redirectProof( Title::newFromText( $title->getFullText() . '/' . $announcementsSubpageName ) ); if ( $announcementsTitle->exists() || $announcementsText !== null ) { if ( $announcementsText === null ) { @@ -515,7 +533,7 @@ if ( !isset( $item['title'] ) || $item['title'] == '' ) { continue; } - $spTitle = Title::newFromText( $item['title'] ); + $spTitle = $this->redirectProof( Title::newFromText( $item['title'] ) ); $spRev = Revision::newFromTitle( $spTitle ); // open element and do header @@ -607,7 +625,7 @@ static $tocLinks = []; // All used ids for the sections for the toc $linkRenderer = $wgParser->getLinkRenderer(); - $spTitle = Title::newFromText( $contentItem['title'] ); + $spTitle = $this->redirectProof( Title::newFromText( $contentItem['title'] ) ); $spRev = Revision::newFromTitle( $spTitle ); // Get display name -- To view, visit https://gerrit.wikimedia.org/r/339814 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5a251c426c3664c07e2dedea95b010836d070920 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CollaborationKit Gerrit-Branch: master Gerrit-Owner: Harej <jamesmh...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits