From: jenkins-bot Date: Sat, 13 Jul 2019 18:02:27 +0000 (+0000) Subject: Merge "Title: Title::getSubpage should not lose the interwiki prefix" X-Git-Tag: 1.34.0-rc.0~1028 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=c05b8b7c473a7dd9c832f91366c45cb8a35c2df2;hp=837f2d76ae358d7cfc6b45bcaf62ddf758c23d8f Merge "Title: Title::getSubpage should not lose the interwiki prefix" --- diff --git a/includes/Title.php b/includes/Title.php index b9b1bb7947..28bec0bdce 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1887,7 +1887,12 @@ class Title implements LinkTarget, IDBAccessObject { * @since 1.20 */ public function getSubpage( $text ) { - return self::makeTitleSafe( $this->mNamespace, $this->getText() . '/' . $text ); + return self::makeTitleSafe( + $this->mNamespace, + $this->getText() . '/' . $text, + '', + $this->mInterwiki + ); } /** diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index 4ffef02d19..d0a95c252f 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -1,5 +1,6 @@ getMock( InterwikiLookup::class ); + $interwikiLookup->expects( $this->any() ) + ->method( 'isValidInterwiki' ) + ->willReturnCallback( + function ( $prefix ) { + return $prefix == 'wiki'; + } + ); + + $this->setService( 'InterwikiLookup', $interwikiLookup ); + + $title = Title::newFromText( $title ); + $expected = Title::newFromLinkTarget( $expected ); + $actual = $title->getSubpage( $sub ); + + // NOTE: convert to string for comparison + $this->assertSame( $expected->getPrefixedText(), $actual->getPrefixedText(), 'text form' ); + $this->assertTrue( $expected->equals( $actual ), 'Title equality' ); + } + public static function provideNewFromTitleValue() { return [ [ new TitleValue( NS_MAIN, 'Foo' ) ],