From 229db67347f11093ac32fc84d31c05fe1515b85a Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 26 Sep 2016 17:14:05 -0700 Subject: [PATCH] Fix links to sections with [[links]] in their title We would generate things like #Foo_.5B.5Bbar.5D.5D instead of #Foo_bar . Unfortunately this doesn't fix section titles with templates / magic words in them, because those are parsed at notification render time instead of at notification generation time. Bug: T134216 Change-Id: Ia171324a4a616c956ab08fcff38293f18dc765fa --- includes/formatters/PresentationModelSectionTrait.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/formatters/PresentationModelSectionTrait.php b/includes/formatters/PresentationModelSectionTrait.php index f09e75a2e..a286330d4 100644 --- a/includes/formatters/PresentationModelSectionTrait.php +++ b/includes/formatters/PresentationModelSectionTrait.php @@ -45,13 +45,16 @@ trait EchoPresentationModelSectionTrait { * @return Title */ protected function getTitleWithSection() { + global $wgParser; $title = $this->event->getTitle(); $section = $this->getSection(); + // guessSectionNameFromWikiText() returns '#foo', strip the '#' + $fragment = substr( $wgParser->guessSectionNameFromWikiText( $section ), 1 ); if ( $section ) { $title = Title::makeTitle( $title->getNamespace(), $title->getDBkey(), - $section + $fragment ); } return $title;