From: Tim Starling Date: Thu, 25 Oct 2018 23:14:15 +0000 (-0700) Subject: Fix use of non-existent variable Parser::$config X-Git-Tag: 1.34.0-rc.0~3646 X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=a6a017cea454458216aca5f06251b2e9b86bd9e3 Fix use of non-existent variable Parser::$config Fix bug from Ib4394f370cb561ccf195338a1c2e9e465dcb3dc3 Add test. Bug: T208000 Change-Id: Ia81cca1b64afef2af3cb8dff19719a7f0de9d306 --- diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index db0407752b..3509200c99 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -5925,7 +5925,7 @@ class Parser { } private function makeLegacyAnchor( $sectionName ) { - $fragmentMode = $this->config->get( 'FragmentMode' ); + $fragmentMode = $this->siteConfig->get( 'FragmentMode' ); if ( isset( $fragmentMode[1] ) && $fragmentMode[1] === 'legacy' ) { // ForAttribute() and ForLink() are the same for legacy encoding $id = Sanitizer::escapeIdForAttribute( $sectionName, Sanitizer::ID_FALLBACK ); diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php index 291d75b677..d70208460b 100644 --- a/tests/phpunit/includes/parser/ParserMethodsTest.php +++ b/tests/phpunit/includes/parser/ParserMethodsTest.php @@ -370,6 +370,21 @@ class ParserMethodsTest extends MediaWikiLangTestCase { } } + public static function provideGuessSectionNameFromWikiText() { + return [ + [ '1/2', 'html5', '#1/2' ], + [ '1/2', 'legacy', '#1.2F2' ], + ]; + } + + /** @dataProvider provideGuessSectionNameFromWikiText */ + public function testGuessSectionNameFromWikiText( $input, $mode, $expected ) { + $this->setMwGlobals( [ 'wgFragmentMode' => [ $mode ] ] ); + global $wgParser; + $result = $wgParser->guessSectionNameFromWikiText( $input ); + $this->assertEquals( $result, $expected ); + } + // @todo Add tests for cleanSig() / cleanSigInSig(), getSection(), // replaceSection(), getPreloadText() }