Commit graph

25 commits

Author SHA1 Message Date
addshore 2d6e567bc5 Fix PageContentSaveComplete hook WikiPage typehint
Change-Id: I615c77593c2407b59a95e710e3396a419f0d66d9
2017-12-08 18:54:35 +00:00
Kunal Mehta a544c227f2 Avoid hardcoding specific GadgetRepo implementations for cache invalidations
Depending on GadgetRepo::singleton() to return a specific implementation
is fragile. Pass each created/updated/deleted page to
GadgetRepo::handlePageCreation/Update/Deletion() and let each specific
implementation deal with it.

Use LinkTarget to be TitleValue compatible for the future.

Change-Id: Ibe2e26d12369a897c53757adf621926f62af7f7b
2017-11-07 12:13:11 -08:00
Sam Wilson 0e002e8a57 Opt out of being available as a global preference
Bug: T175118
Depends-On: I9cad21057472bee83d8146cc6992be07bc65a717
Change-Id: Id6df3fd233471048a84edfdd2b7876b3b84b8c66
2017-09-06 16:07:07 +08:00
Umherirrender 88d0b22359 Improve some parameter docs
Change-Id: I268aaa13d07985b0915774e83c487cd22568b161
2017-08-27 16:07:08 +02:00
Umherirrender f102194baf Add phpcs and make pass
Change-Id: I02b7f85f54ffaf8a1c9d5bed6fa20abb1627afe5
2017-05-31 16:36:45 +02: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
Timo Tijhof d1d8bd73df Change warning link about type=general from phab to mediawiki.org
Bug: T42284
Change-Id: Ibb5dcca242e75567ab2ee70b0836b2271fe171d0
2017-02-15 13:23:25 -08:00
Timo Tijhof dc4ea6cb21 Implement 'peers' feature for loading extra styles-type gadgets
Ref discussion on T42284.

Test plan:
* Create gadget A with a .css file only. (Maybe mark as 'hidden')
* Create gadget B with .js file, and peers=A.
* Verify that enabling B will result in B being loaded as general module,
  and A being loaded as page style module.

Change-Id: Ib6207e72c576ff387ecdba685a063bdfbb828199
2017-01-02 14:45:09 +01: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
Reedy 7c922c92b9 Replace ArticleSaveComplete hook usage
Bug: T147556
Change-Id: I6f3a58c8e7cf1382fc8e1ac30cc697deb7fc9eb7
2016-10-06 17:16:15 +01: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 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
niharika29 e03ff36127 Add wgQueryPages hook for Special:GadgetUsage page
Change-Id: Ifacd705886f923e3ee58d4cd004d50c8ec4002d8
2015-10-27 13:29:26 +00:00
Kunal Mehta 152484566d Add support for 'messages' and 'hidden' gadgets
In the backend, allow:
* Adding dependencies on messages
* Marking gadgets as hidden so they don't show in preferences

These cannot be used by MediaWiki:Gadgets-definition gadgets, but will
be used by Gadgets 2.0 gadgets.

Change-Id: I55e97de9d631ae001ccc0164db172ba9c5689a34
2015-08-08 00:43:16 +00:00
Timo Tijhof 29e7a9193d Don't load legacy gadget scripts
The time has come to stop supporting legacy gadgets that haven't
migrated to ResourceLoader yet.

For many Gadgets, migrating to ResourceLoader will be as easy
as adding "[ResourceLoader]" to its definition on MediaWiki:Gadgets-definition.

However for older gadgets, they may need more maintenance. Though
similarly they may've already been malfunctioning silently.

The most common techniques used by legacy scripts, and what their
equivalents are in modern JavaScript, see:
<https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_(users)>

Ref T107399.

Change-Id: Ia5f7323a40a28541515ef3a3f5079f1cc940f392
2015-08-07 01:00:40 +00: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 a51bb552dc Revert "Add $wgGadgetsEnableLegacyGadgets to allow disabling of legacy gadgets"
This reverts commit 036aa3d876.

Change-Id: I90840cbdaa1d6eabde3fffd113dc7a945a876e77
2015-07-18 07:44:31 +00:00
Kunal Mehta 036aa3d876 Add $wgGadgetsEnableLegacyGadgets to allow disabling of legacy gadgets
Follows-up 192d37b19a.

So we can turn them off in preparation of Gadgets 2.0, which
doesn't support them at all.

Change-Id: I98b4146579ccbbfcad8b83a51cc095da1fad673c
2015-07-04 01:25:26 +01: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
Chad Horohoe fb5c2ba40e Remove obvious function-level profiling
Change-Id: If6ce3558357a64ce5054a40e493d65a07956f471
2015-02-12 11:48:44 -08:00
Max Semenik 0a1a4f4438 Profiling
Change-Id: I4988e95e953f55bc96779c4fcc7d94553d5b3b0c
2013-08-30 03:43:17 +04:00
Max Semenik 0ee165bce8 Move hooks to a separate file
Change-Id: I2cb53bd4beae247c1b983dc8c4482af682acab64
2013-08-30 03:35:07 +04:00