MinervaPermissions must respect $wgHideInterlanguageLinks config
MediaWiki Core defined $wgHideInterlanguageLinks that can be used to disable the interwiki links. Minerva skin should respect this config, furthermore, this config should take precedence over the Minerva's $wgMinervaAlwaysShowLanguageButton config. Bug: T214540 Bug: T221792 Change-Id: Id4fe8b67a17f9c28c00a8a3a207946e146502cde
This commit is contained in:
parent
8c7553935e
commit
bb0071383a
|
@ -108,11 +108,18 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
||||||
* @throws ConfigException
|
* @throws ConfigException
|
||||||
*/
|
*/
|
||||||
public function isAllowed( $action ) {
|
public function isAllowed( $action ) {
|
||||||
|
global $wgHideInterlanguageLinks;
|
||||||
|
|
||||||
// T206406: Enable "Talk" or "Discussion" button on Main page, also, not forgetting
|
// T206406: Enable "Talk" or "Discussion" button on Main page, also, not forgetting
|
||||||
// the "switch-language" button. But disable "edit" and "watch" actions.
|
// the "switch-language" button. But disable "edit" and "watch" actions.
|
||||||
if ( $this->title->isMainPage() ) {
|
if ( $this->title->isMainPage() ) {
|
||||||
return ( in_array( $action, $this->config->get( 'MinervaPageActions' ) )
|
if ( !in_array( $action, $this->config->get( 'MinervaPageActions' ) ) ) {
|
||||||
&& ( $action === self::TALK || $action === self::SWITCH_LANGUAGE ) );
|
return false;
|
||||||
|
}
|
||||||
|
if ( $action === self::SWITCH_LANGUAGE ) {
|
||||||
|
return !$wgHideInterlanguageLinks;
|
||||||
|
}
|
||||||
|
return $action === self::TALK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $action === self::HISTORY && $this->title->exists() ) {
|
if ( $action === self::HISTORY && $this->title->exists() ) {
|
||||||
|
@ -138,6 +145,9 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $action === self::SWITCH_LANGUAGE ) {
|
if ( $action === self::SWITCH_LANGUAGE ) {
|
||||||
|
if ( $wgHideInterlanguageLinks ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$hasVariants = $this->title->getPageLanguage()->hasVariants();
|
$hasVariants = $this->title->getPageLanguage()->hasVariants();
|
||||||
$hasLanguages = count( $this->output->getLanguageLinks() );
|
$hasLanguages = count( $this->output->getLanguageLinks() );
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,28 @@ class MinervaPagePermissionsTest extends MediaWikiTestCase {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MediaWiki defines wgHideInterlanguageLinks which is default set to false, but some wikis
|
||||||
|
* can set this config to true. Minerva page permissions must respect that
|
||||||
|
* @covers ::isAllowed
|
||||||
|
*/
|
||||||
|
public function testGlobalHideLanguageLinksTakesPrecedenceOnMainPage() {
|
||||||
|
$this->setMwGlobals( [ 'wgHideInterlanguageLinks' => true ] );
|
||||||
|
$perms = $this->buildPermissionsObject( Title::newMainPage() );
|
||||||
|
$this->assertFalse( $perms->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MediaWiki defines wgHideInterlanguageLinks which is default set to false, but some wikis
|
||||||
|
* can set this config to true. Minerva page permissions must respect that
|
||||||
|
* @covers ::isAllowed
|
||||||
|
*/
|
||||||
|
public function testGlobalHideLanguageLinksTakesPrecedence() {
|
||||||
|
$this->setMwGlobals( [ 'wgHideInterlanguageLinks' => true ] );
|
||||||
|
$perms = $this->buildPermissionsObject( Title::newFromText( 'test' ) );
|
||||||
|
$this->assertFalse( $perms->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "switch-language" page action is allowed when: v2 of the page action bar is enabled and
|
* The "switch-language" page action is allowed when: v2 of the page action bar is enabled and
|
||||||
* if the page has interlanguage links or if the <code>$wgMinervaAlwaysShowLanguageButton</code>
|
* if the page has interlanguage links or if the <code>$wgMinervaAlwaysShowLanguageButton</code>
|
||||||
|
|
Loading…
Reference in New Issue