mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-13 17:53:22 +00:00
Merge "Fix parsing logic when comments or hidden characters are present"
This commit is contained in:
commit
95e524ffe7
|
@ -303,8 +303,7 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( preg_split( '/\s*\|\s*/', $pages, -1, PREG_SPLIT_NO_EMPTY ) as $page ) {
|
foreach ( preg_split( '/\s*\|\s*/', $pages, -1, PREG_SPLIT_NO_EMPTY ) as $page ) {
|
||||||
$page = $this->titlePrefix . $page;
|
$info['pages'][] = $this->titlePrefix . trim( $page );
|
||||||
$info['pages'][] = $page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Gadget( $info );
|
return new Gadget( $info );
|
||||||
|
|
|
@ -18,6 +18,8 @@ class MediaWikiGadgetsDefinitionRepoTest extends MediaWikiIntegrationTestCase {
|
||||||
* baz [rights=read] |baz.js
|
* baz [rights=read] |baz.js
|
||||||
==keep-section2==
|
==keep-section2==
|
||||||
* quux [rights=read] | quux.js
|
* quux [rights=read] | quux.js
|
||||||
|
* g1 [ResourceLoader | default | namespaces=2 | rights=editmyuserjs] | g1.js <!-- comment -->
|
||||||
|
* g2 [ResourceLoader | default | namespaces=2 | rights=editmyuserjs] | <!-- comment --> g2.js
|
||||||
EOT;
|
EOT;
|
||||||
$this->editPage( 'MediaWiki:Gadgets-definition', $gadgetsDef );
|
$this->editPage( 'MediaWiki:Gadgets-definition', $gadgetsDef );
|
||||||
|
|
||||||
|
@ -25,10 +27,13 @@ EOT;
|
||||||
$repo = new MediaWikiGadgetsDefinitionRepo( $services->getMainWANObjectCache(),
|
$repo = new MediaWikiGadgetsDefinitionRepo( $services->getMainWANObjectCache(),
|
||||||
$services->getRevisionLookup() );
|
$services->getRevisionLookup() );
|
||||||
$gadgets = $repo->fetchStructuredList();
|
$gadgets = $repo->fetchStructuredList();
|
||||||
$this->assertCount( 4, $gadgets );
|
$this->assertCount( 6, $gadgets );
|
||||||
|
|
||||||
$bar = $repo->getGadget( 'bar' );
|
$bar = $repo->getGadget( 'bar' );
|
||||||
$this->assertEquals( 'keep-section1', $bar->toArray()['category'] );
|
$this->assertEquals( 'keep-section1', $bar->toArray()['category'] );
|
||||||
|
|
||||||
|
$this->assertEquals( [ 'MediaWiki:Gadget-g1.js' ], $repo->getGadget( 'g1' )->getScripts() );
|
||||||
|
$this->assertEquals( [ 'MediaWiki:Gadget-g2.js' ], $repo->getGadget( 'g2' )->getScripts() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue