From 94e140fc687c43babe44722fa068a966ddbe38ee Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 22 Sep 2011 21:35:24 +0000 Subject: [PATCH] * (bug 31100) Fix regression in sidebar (special: page links lost parameters) Regression in Title::fixSpecialName() in r86255; fixed and added a unit test case to TitleTest. --- includes/Title.php | 4 ++-- tests/phpunit/includes/TitleTest.php | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/Title.php b/includes/Title.php index 1f1a6a8f0f..b863f8db6d 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4194,9 +4194,9 @@ class Title { */ public function fixSpecialName() { if ( $this->getNamespace() == NS_SPECIAL ) { - list( $canonicalName, /*...*/ ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform ); + list( $canonicalName, $par ) = SpecialPageFactory::resolveAlias( $this->mDbkeyform ); if ( $canonicalName ) { - $localName = SpecialPageFactory::getLocalNameFor( $canonicalName ); + $localName = SpecialPageFactory::getLocalNameFor( $canonicalName, $par ); if ( $localName != $this->mDbkeyform ) { return Title::makeTitle( NS_SPECIAL, $localName ); } diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index c128fdd8cc..06ee3b2ab5 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -15,4 +15,26 @@ class TitleTest extends MediaWikiTestCase { } } + /** + * @dataProvider dataBug31100 + */ + function testBug31100FixSpecialName( $text, $expectedParam ) { + $title = Title::newFromText( $text ); + $fixed = $title->fixSpecialName(); + $stuff = explode( '/', $fixed->getDbKey(), 2 ); + if ( count( $stuff ) == 2 ) { + $par = $stuff[1]; + } else { + $par = null; + } + $this->assertEquals( $expectedParam, $par, "Bug 31100 regression check: Title->fixSpecialName() should preserve parameter" ); + } + + function dataBug31100() { + return array( + array( 'Special:Version', null ), + array( 'Special:Version/', '' ), + array( 'Special:Version/param', 'param' ), + ); + } } -- 2.20.1