PopupsContext::areDependenciesMet should respect PopupsGateway config

On all wikis Popups use Restbase as default gateway. In that case we
do not require the TextExtracts nor PageImages extensions. Code should
reflect that.

Bug: T190818
Change-Id: If4ce8f709b2ca1bb3cc381afa5e80e978adf2498
This commit is contained in:
Piotr Miazga 2018-03-29 00:53:34 +02:00 committed by jdlrobson
parent 1acd15adb1
commit 915a9708fb
2 changed files with 23 additions and 4 deletions

View file

@ -148,8 +148,12 @@ class PopupsContext {
* @return bool
*/
public function areDependenciesMet() {
$areMet = $this->extensionRegistry->isLoaded( 'TextExtracts' )
$areMet = true;
if ( $this->config->get( 'PopupsGateway' ) === 'mwApiPlain' ) {
$areMet = $areMet && $this->extensionRegistry->isLoaded( 'TextExtracts' )
&& $this->extensionRegistry->isLoaded( 'PageImages' );
}
if ( $this->isBetaFeatureEnabled() ) {
$areMet = $areMet && $this->extensionRegistry->isLoaded( 'BetaFeatures' );

View file

@ -203,9 +203,10 @@ class PopupsContextTest extends MediaWikiTestCase {
* @param bool $expected
*/
public function testAreDependenciesMet( $betaOn, $textExtracts, $pageImages,
$betaFeatures, $expected ) {
$betaFeatures, $gateway, $expected ) {
$this->setMwGlobals( [
"wgPopupsBetaFeature" => $betaOn
"wgPopupsBetaFeature" => $betaOn,
"wgPopupsGateway" => $gateway,
] );
$returnValues = [ $textExtracts, $pageImages, $betaFeatures ];
@ -228,6 +229,7 @@ class PopupsContextTest extends MediaWikiTestCase {
"textExtracts" => true,
"pageImages" => true,
"betaFeatures" => false,
"gateway" => "mwApiPlain",
"expected" => true
],
// textExtracts dep is missing
@ -236,6 +238,7 @@ class PopupsContextTest extends MediaWikiTestCase {
"textExtracts" => false,
"pageImages" => true,
"betaFeatures" => false,
"gateway" => "mwApiPlain",
"expected" => false
],
// PageImages dep is missing
@ -244,6 +247,7 @@ class PopupsContextTest extends MediaWikiTestCase {
"textExtracts" => true,
"pageImages" => false,
"betaFeatures" => false,
"gateway" => "mwApiPlain",
"expected" => false
],
// Beta is on but BetaFeatures dep is missing
@ -252,6 +256,7 @@ class PopupsContextTest extends MediaWikiTestCase {
"textExtracts" => true,
"pageImages" => true,
"betaFeatures" => false,
"gateway" => "mwApiPlain",
"expected" => false
],
// beta is on and all deps are available
@ -260,8 +265,18 @@ class PopupsContextTest extends MediaWikiTestCase {
"textExtracts" => true,
"pageImages" => true,
"betaFeatures" => true,
"gateway" => "mwApiPlain",
"expected" => true
]
],
// when Popups uses gateway!=mwApiPlain we don't require PageImages nor TextExtracts
[
"betaOn" => false,
"textExtracts" => false,
"pageImages" => false,
"betaFeatures" => false,
"gateway" => "restbaseHTML",
"expected" => true
],
];
}