Commit graph

88 commits

Author SHA1 Message Date
Bartosz Dziewoński 82281d82d0 Make each gadget a separate preference, instead of one huge multiselect
This gives each section and each gadget's entry an `id` attribute,
which can be used for linking, as requested in T126962. Existing user
options still match the new preferences.

It also probably makes future improvements easier. No one understands
multiselects with subsections.

Bug: T126962
Change-Id: Ifaca96e288c475017636c2408712d6a20aa77da9
2021-09-30 18:39:41 +02:00
libraryupgrader b5e7230698 build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: Id55b598a81bd22cbe0f415f32fd28ba3825bf61e
2021-07-22 20:01:41 +00:00
Umherirrender e9f6ea3492 Reduce message parse in GadgetHooks::getPreferences (second time)
Multiselect can build by message keys only and allows to parse them.

This reverts fix for T32182, there is no way to handle the dir on each
item/checkbox at the moment

Reintroduce Iccd6202c443bd699aa3a911c8ba36a2b7bcdcfed (reverted by
I1cf3c7c61e9e90567587350639590691add1af34)

Bug: T58633
Bug: T278650
Depends-On: I8f52f21ae2641ddcad1aa85ce6bf14de1a09ab4b
Change-Id: If71008195f58faff9f302f7ea2bf9dbb1a527844
2021-05-28 20:52:58 +02:00
libraryupgrader c3c98c1146 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I5e0b9e78f0436355cc21dc356fb78e96e59cb536
2021-05-04 18:43:54 +00:00
Jforrester b50309db2c Revert "Reduce message parse in GadgetHooks::getPreferences"
This reverts commit 662c63882c.

Reason for revert: plain() is too plain for our needs, sadly.

Change-Id: I1cf3c7c61e9e90567587350639590691add1af34
2021-04-21 21:55:32 +00:00
Umherirrender 662c63882c Reduce message parse in GadgetHooks::getPreferences
Multiselect can build by message keys only

This reverts fix for T32182, there is no way to handle the dir on each
item/checkbox at the moment

Bug: T58633
Bug: T278650
Depends-On: Ie983757081dc39f3685ba5b01b02bd124880e1af
Change-Id: Iccd6202c443bd699aa3a911c8ba36a2b7bcdcfed
2021-04-20 18:49:19 +00:00
libraryupgrader b95f062426 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 34.0.0 → 35.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.18.1

Additional changes:
* Added the "composer phan" command to conveniently run phan.
* Removing manual extensions for eslint.

Change-Id: Ia5e47e750485b1499c9a0899407e24bfdfddacd4
2021-01-29 13:35:14 +00:00
libraryupgrader d9afecbd84 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate

Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: I5fa8001a2ea7fdab2dbf9ce8cba9d1764f7a4562
2020-01-14 05:38:11 +00:00
James D. Forrester ed181c2db0 build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I61896470e0dc9cffd3e8fff8b45e2231ef4265f3
2019-10-09 16:24:09 -07:00
Derk-Jan Hartman 2008def806 Only queue gadget module if relevant on the current target
Bug: T171180
Depends-On: Ibe693bb6a84bdf56fd22d1ea1f0b798094b91c62
Change-Id: Ibce4d642c87651880f3c981dfa0d68def3bddd3a
2019-10-02 19:43:15 +00:00
Max Semenik 7d1b74d8c7 Split tests to unit and integration
Change-Id: Ib703086c38b6b1ca13f37504c5b6eab6834694b8
2019-07-23 02:23:41 -07:00
Max Semenik 2470a59218 Hook handlers don't always need to return something
And other minor fixes to hook signatures.

Change-Id: Ib6d8c9dff5bb79386ac88828ba2a57a9bf81ee71
2019-07-23 02:23:27 -07:00
Kunal Mehta b28ad14b8c Upgrade to newer phan
Bug: T216919
Change-Id: I3a403891eafa703215a79526fcf9469b1fd6edc6
2019-03-17 16:39:02 -07:00
jenkins-bot ef4c537d9e Merge "Fix skins option to use currently displayed skin, rather than user preference" 2018-08-03 18:53:39 +00:00
Matt Russell b340532c52 Fix skins option to use currently displayed skin, rather than user preference
The user's preference usually reflects the displayed skin, however this isn't
true if the `useskin` URL query is set, or MobileFrontend is being used.

This fixes gadgets being displayed on the wrong skin when using `useskin`,
and allows mobile-specific gadgets (using `skins=minerva`).

Testing if the gadget is allowed in the current skin is split out from
`isAllowed` to `isSkinSupported` to enable a future patch showing gadgets
on preferences regardless of if they are allowed on the current skin.
Test coverage is added for both functions.

Also fixed another test which wasn't working, presumably because the placeholder
user didn't have the "read" right, so the section wasn't being kept.

Bug: T199478
Change-Id: I21febe92d54d6d0b89925f902581cc2739d824fb
2018-08-01 11:06:17 +10:00
Thiemo Kreuz bede1c0178 More loose @covers annotations in GadgetTest
This is more an integration test than anything. The @covers tags I found
are to strict, in my opinion. These test cases cover more code.

Change-Id: I6cef7ce0c612ac3dfbb855c495032df1fe96f4af
2018-07-31 18:38:26 +02:00
Kunal Mehta 441302fb5e build: Updating mediawiki/mediawiki-phan-config to 0.2.0
Change-Id: I4d364243c33243aceeff9793bc3e69efd62ae491
2018-04-05 13:25:35 -07:00
Kunal Mehta e99e181303 Add phan configuration
Depends-On: I09a0c0a786b687997e61344847f8af08b20cebf2
Change-Id: I9500232fb524e884d6cb15f2bdda10835df35ad4
2018-02-26 12:57:40 -08:00
Kunal Mehta 677d4e932c Move classes into includes/
Change-Id: I10bc5234ad2ebeed2514aafc3dbe2a0afa983bd8
2018-02-25 11:19:23 +00:00
Timo Tijhof eabfab52e0 tests: Add @covers tags
Change-Id: Ia3e18e7149292cd23765636111acc846564bf6cc
2018-01-05 00:11:10 +00:00
Umherirrender f102194baf Add phpcs and make pass
Change-Id: I02b7f85f54ffaf8a1c9d5bed6fa20abb1627afe5
2017-05-31 16:36:45 +02:00
Thiemo Mättig 6b22f1089e Use …->assertArrayHasKey() instead of isset()
… as well as update a line of documentation I had stashed. I think this
does not need it's own patch, or does it?

Change-Id: I99eee1f7b5ec96c1c75e73d66200bc41807452fa
2017-05-31 07:52:18 +00:00
Timo Tijhof 3dd92c6f76 Remove duplicate loading of styles (assume type=general if content is mixed)
Follows-up dc834f3, dc4ea6c.

Bug: T92459
Bug: T42284
Change-Id: I94dbdb052a78bbbc3c1b7b8bb8805a5f327670d9
2017-05-12 21:44:42 +00:00
Gergő Tisza b5befcbbe2 Switch TestingAccessWrapper to librarized version
Bug: T163434
Change-Id: I493d9b28d2c0d265e003a9851746eb07c7d15770
Depends-On: I52cc257e593da3d6c3b01a909e554a950225aec8
2017-04-20 11:35:09 +00:00
Fomafix 1a569b590b Convert PHP syntax from array() to []
Performed using:
find . -name \*.php -exec php ~/convert.php -w "{}" \;

Script from:
https://github.com/thomasbachem/php-short-array-syntax-converter

And convert syntax in comments manually.

Change-Id: I7ea9e57f9ab1250c8687885ad9e010771603bf78
2016-12-28 13:51:30 +01:00
Timo Tijhof 27a0ca6568 Implement support for 'hidden' feature in MediaWikiGadgetsDefinitionRepo
Follows-up 152484566, which added support for it in Gadgets 2.0, but
it's easy enough to make it work in existing definitions as well.

That way, people can stop using 'rights=hidden' hacks.

Bug: T33150
Change-Id: Idd6944a9ad38279e117c1a02a4b5fd0343455ba0
2016-11-22 23:46:38 +00:00
Timo Tijhof 846b979578 Remove redundant 'position', 'top', and getPosition() code
Unused as of bc374082fa in MediaWiki core (T109837).

Change-Id: Idcec3c4fa2bc3bc05ac417062139794880040a6d
2016-11-18 13:55:30 -08:00
Timo Tijhof 906aaeeb82 Default to type=general for styles-only gadgets having dependencies
Bug: T147726
Change-Id: I4153851b0e2f5cc067b1f31a7cd80f73d0620d7c
2016-11-16 17:53:10 -08:00
Timo Tijhof dc834f3933 Implement support for specifying type=styles
T87871 formally introduced the concept of a styles module,
which sets mw.loader.state to "ready" when loaded through addModuleStyles().

Previously, addModuleStyles couldn't safely do that because a module may
contain scripts also, in which case mw.loader must still load the (rest)
of the module (causes styles to load twice).

In MediaWiki core or extensions this is easily avoided by calling not
calling both addModules() and addModuleStyles().

For Gadgets we call both as a workaround to allow users to provide styles
(without a FOUC), but also to provide scripts+styles. Since we don't declare
which one is intended (and some gadgets do both), we loaded them both ways.
This will no longer be allowed in the future (see T92459).

The new 'type=styles' Gadget attribute promises to ResourceLoader that a
gadget only contains styles.

Impact:

* [Bug fix] When mw.loader requires a styles module that already loaded,
            it will not load again.

* [Feature] It is possible for a general scripts+styles gadget to depend on
            a styles gadget. Previously this caused the styles to load twice.

* Specifying type=styles will load the module through addModuleStyles() only.

  Use this for modules that contain styles that relate to elements already
  on the page (e.g. when customising the skin, layout, or article content).

* Specifying type=general will load the module through addModules() only.

  Use this if your module contains both scripts and styles and the styles
  only relate to elements created by the script. This means the styles do not
  need to be loaded separately through addModuleStyles() and will not apply
  to noscript mode.

Effective difference:

* Gadgets with only styles: We assume type=styles.

  This fixes the main bug (styles loading twice) and requires no migration!

* Gadgets with only scripts: We assume type=general.

  This requires no migration! (And: No more empty stylesheet request)

* Gadgets with scripts (with or without styles): We assume type=general, but
  unless type=general was explicitly set we'll still load it both ways so
  that the styles apply directly on page load.

  If this is not needed, set type=general.

  If this is needed, it should become two separate modules. We do not support
  a single module having two purposes (1: apply styles to the page,
  2: provide scripts+styles). The styles module should be separate.
  It can be made hidden, and listed as dependency of the other module.

The latter case is detected on page load and results in a console warning
with a link to T42284.

Bug: T42284
Bug: T92459
Change-Id: Ia3c9ddee243f710022144fc2884434350695699a
2016-09-30 10:43:29 +00:00
Reedy 34795a8803 Remove 'UnitTestList' hook
No longer needed now that extension unittests are autodiscovered.

Bug: T142120
Bug: T142121
Change-Id: I89cfc1ea3e652ebec1cd67f62810586c4ef49574
2016-08-06 01:14:53 -07:00
Kunal Mehta 5257a2112c Unbreak tests
Bug: T142236
Change-Id: Id30ea70a00a8e3ebcd71801cbbab694f99ce3f00
2016-08-06 01:14:09 -07:00
Kunal Mehta 519f30355e Implement Gadgets definition namespace repo
Implements:
* Gadget definition content and content handler
* Basic validation for gadget definition content
* GadgetDefinitionNamespace implementation of GadgetRepo
* DataUpdates upon editing/deletion of Gadget definition pages
* EditFilterMerged hook for improved error messages
* 'GadgetsRepoClass' option to switch GadgetRepo implementation used
* Lazy-load the GadgetResourceLoaderModule class so we don't need to
load each individual gadget object unless its needed

Note that Special:Gadgets's export feature intentionally doesn't work
yet, and will be fixed in a follow up patch.

Bug: T106177
Change-Id: Ib11db5fb0f7b46793bfa956cf1367f1dc1059b1c
2015-11-20 12:01:21 -06:00
Kunal Mehta e858bda308 Add abstract GadgetRepo and MediaWikiGadgetsDefinition implementation
GadgetRepo is an abstract class based off of the implementation in the
RL2 branch.

It is a singleton that provides basic methods to construct and interact
with Gadget objects.

The MediaWikiGadgetsDefinition class is an implementation of GadgetsRepo
that parses the "MediaWiki:Gadgets-definition" page for gadget
definitions.

Tests were left in place to demonstrate that no functional changes have
been made aside from relocation of code. Some tests should be moved to
separate files in the future.

Bug: T106176
Change-Id: I3e802889f6f495783f4dbac65c2a8cefa824a778
2015-08-01 15:10:07 -07:00
Alex Monk ca8880a634 Set 644 file permissions on .php files
Bug: T104039
Change-Id: I5a040819ae53ce9e4da7ed542ed1f74253129a86
2015-06-27 18:50:31 +01:00
Thiemo Mättig 5b1f8a1e50 Update api module constructors
This also replaces a deprecated function and adds some code docs.

Change-Id: I22c77d370469c10cad5d504b06280e933eeeeeff
2015-06-17 20:42:20 +02:00
Aaron Schulz 11e1c51d6b Conversion to using WAN cache
* Bumped the key version due to key wrapping
* Removed isValidList() gived the key versioning
* Follow up ba1311c323 by making APC viable;
  previously, definition purges would not work

Bug: T93141
Change-Id: I6da3eede044bf4b840b3f9656a1ae8105941dc6b
2015-05-23 23:04:06 +00:00
Max Semenik c2be054951 Improve tests
* Reduce globals usage thanks to core improvements
* Use new assertion that wasn't available before

Change-Id: I9b7fb065ea9e235e6c5e7ea5116ccacac91f8846
2014-06-26 17:34:27 -07:00
Timo Tijhof eca021ed61 tests: Rename file to end in Test.php
Though the hook registration was working fine, the run from
Jenkins was failing.

Jenkins runs like this:

 $ php tests/phpunit/phpunit.php extensions/Gadgets

Which bypasses UnitTestsList and uses auto-discovery within the
given directory of "*.Test.php" files.

Renamed to file to match PHPUnit's internal discovery pattern
and updated the onUnitTestsList callback to use this pattern
as well.

Also updated documentation applied recent code conventions in
this area (extend MediaWikiTestCase).

Change-Id: Iaa52a5eafdebf1529dd02fb1bed89d27c298e0d3
2013-05-01 03:20:39 +02:00