mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-30 18:14:21 +00:00
Only queue gadget module if relevant on the current target
Bug: T171180 Depends-On: Ibe693bb6a84bdf56fd22d1ea1f0b798094b91c62 Change-Id: Ibce4d642c87651880f3c981dfa0d68def3bddd3a
This commit is contained in:
parent
c9e4a54ec4
commit
2008def806
|
@ -160,7 +160,6 @@ class GadgetHooks {
|
|||
* @var $gadget Gadget
|
||||
*/
|
||||
$user = $out->getUser();
|
||||
$skin = $out->getSkin();
|
||||
foreach ( $ids as $id ) {
|
||||
try {
|
||||
$gadget = $repo->getGadget( $id );
|
||||
|
@ -178,7 +177,8 @@ class GadgetHooks {
|
|||
}
|
||||
if ( $gadget->isEnabled( $user )
|
||||
&& $gadget->isAllowed( $user )
|
||||
&& $gadget->isSkinSupported( $skin )
|
||||
&& $gadget->isSkinSupported( $out->getSkin() )
|
||||
&& ( in_array( $out->getTarget() ?? 'desktop', $gadget->getTargets() ) )
|
||||
) {
|
||||
if ( $gadget->hasModule() ) {
|
||||
if ( $gadget->getType() === 'styles' ) {
|
||||
|
|
|
@ -101,6 +101,17 @@ class GadgetTest extends MediaWikiUnitTestCase {
|
|||
$this->assertFalse( $gSkinNotSupported->isSkinSupported( $skin ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MediaWikiGadgetsDefinitionRepo::newFromDefinition
|
||||
* @covers Gadget::getTargets
|
||||
*/
|
||||
public function testTargets() {
|
||||
$g = $this->create( '*foo[ResourceLoader]|foo.js' );
|
||||
$g2 = $this->create( '*bar[ResourceLoader|targets=desktop,mobile]|bar.js' );
|
||||
$this->assertEquals( [ 'desktop' ], $g->getTargets() );
|
||||
$this->assertEquals( [ 'desktop', 'mobile' ], $g2->getTargets() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers MediaWikiGadgetsDefinitionRepo::newFromDefinition
|
||||
* @covers Gadget::getDependencies
|
||||
|
|
Loading…
Reference in a new issue