* (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.
This commit is contained in:
parent
c94639fe2d
commit
94e140fc68
2 changed files with 24 additions and 2 deletions
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue