ApiQuerySiteinfo: Fix "rightsinfo"/"url" when $wgRightsPage is set
Bug: T295191 Change-Id: I181b29dbdc8374837789c1d900577e49f62bd8d3
This commit is contained in:
parent
0496e036b5
commit
b1b1ec343f
2 changed files with 18 additions and 5 deletions
|
|
@ -769,9 +769,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
|
|||
protected function appendRightsInfo( $property ) {
|
||||
$config = $this->getConfig();
|
||||
$rightsPage = $config->get( 'RightsPage' );
|
||||
if ( is_string( $rightsPage ) ) {
|
||||
// The default value is null, but the installer sets it to empty string
|
||||
if ( strlen( $rightsPage ) ) {
|
||||
$title = Title::newFromText( $rightsPage );
|
||||
$url = wfExpandUrl( $title, PROTO_CURRENT );
|
||||
$url = wfExpandUrl( $title->getLinkURL(), PROTO_CURRENT );
|
||||
} else {
|
||||
$title = false;
|
||||
$url = $config->get( 'RightsUrl' );
|
||||
|
|
|
|||
|
|
@ -477,15 +477,27 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
|
|||
'wgRightsUrl' => $url,
|
||||
'wgRightsText' => $text,
|
||||
] );
|
||||
|
||||
$this->assertSame(
|
||||
[ 'url' => $expectedUrl, 'text' => $expectedText ],
|
||||
$this->doQuery( 'rightsinfo' )
|
||||
);
|
||||
|
||||
// The installer sets these options to empty string if not specified otherwise,
|
||||
// test that this behaves the same as null.
|
||||
$this->setMwGlobals( [
|
||||
'wgRightsPage' => $page ?? '',
|
||||
'wgRightsUrl' => $url ?? '',
|
||||
'wgRightsText' => $text ?? '',
|
||||
] );
|
||||
$this->assertSame(
|
||||
[ 'url' => $expectedUrl, 'text' => $expectedText ],
|
||||
$this->doQuery( 'rightsinfo' ),
|
||||
'empty string behaves the same as null'
|
||||
);
|
||||
}
|
||||
|
||||
public function rightsInfoProvider() {
|
||||
$textUrl = wfExpandUrl( Title::newFromText( 'License' ), PROTO_CURRENT );
|
||||
$textUrl = wfExpandUrl( Title::newFromText( 'License' )->getLinkURL(), PROTO_CURRENT );
|
||||
$url = 'http://license.example/';
|
||||
|
||||
return [
|
||||
|
|
@ -499,7 +511,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
|
|||
'Page and text' => [ 'License', null, '!!!', $textUrl, '!!!' ],
|
||||
'Page and URL and text' => [ 'License', $url, '!!!', $textUrl, '!!!' ],
|
||||
'Pagename "0"' => [ '0', null, null,
|
||||
wfExpandUrl( Title::newFromText( '0' ), PROTO_CURRENT ), '0' ],
|
||||
wfExpandUrl( Title::newFromText( '0' )->getLinkURL(), PROTO_CURRENT ), '0' ],
|
||||
'URL "0"' => [ null, '0', null, '0', '' ],
|
||||
'Text "0"' => [ null, null, '0', '', '0' ],
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in a new issue