Commit graph

83 commits

Author SHA1 Message Date
Kunal Mehta 677d4e932c Move classes into includes/
Change-Id: I10bc5234ad2ebeed2514aafc3dbe2a0afa983bd8
2018-02-25 11:19:23 +00:00
Thiemo Mättig f564d52d9a Fix PHPDocs of GadgetDefinitionContent::getDeletionUpdates
DataUpdate is a specific implementation (currently the only one), while
DeferrableUpdate is the interface. Binding against the interface is
enough, and what the base classes already do.

I'm also removing a line of meaningless documentation. "Creates an
instance of this class" is a general description that is true for all
constructors.

Change-Id: Ia6dc86b078628db5e0ab68ef46bf0396567b767c
2018-01-24 14:51:16 +01: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
libraryupgrader 969027392e build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: I40598f8c34691bbe7b217aa38f24f150a210e2f3
2017-09-24 05:26:03 +00:00
jenkins-bot bea78b0726 Merge "Account for DB lag in loadGadgets() caching" 2017-09-01 02:09:40 +00:00
Aaron Schulz 155d108c02 Account for DB lag in loadGadgets() caching
Bug: T157210
Change-Id: I86a32407af4d6ebb4fa2e16005c76081a113e8c8
2017-08-31 15:29:05 -07:00
Umherirrender 88d0b22359 Improve some parameter docs
Change-Id: I268aaa13d07985b0915774e83c487cd22568b161
2017-08-27 16:07:08 +02:00
jenkins-bot 371cfc1936 Merge "Move gadget styles from main stylesheet request to site request" 2017-06-21 20:32:46 +00:00
Kunal Mehta 837c8403fd build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I38d7f39d2d00e8d26dad4c6281885b54203b23b7
2017-06-20 00:06:01 -07:00
Timo Tijhof 8c35ed5cf1 Move gadget styles from main stylesheet request to site request
This is a resubmission of 86905f8, which was reverted because
of a bug in ResourceLoader that caused gadget styles to be
concatenated in the request for site.styles (fixed: 15ca48ad).

This change ensures that gadget styles no longer get combined with styles
from core, skins and extensions in their early stylesheet request. Instead,
they now load after the 'ResourceLoaderDynamicStyles' marker directly
after the site.styles module request.

Bug: T147667
Change-Id: I16b9901de78e7ee913c4faa55ff9fc9c77fe73ba
2017-06-07 18:36:17 +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
Legoktm ccf1f6818d Revert "Move gadget styles from main stylesheet request to site request"
This reverts commit 86905f8d78.

Bug: T165040
Bug: T165031
Change-Id: I523f46f442946c4cccd6f9eaedc877d871643672
2017-05-11 17:15:20 +00:00
Timo Tijhof 86905f8d78 Move gadget styles from main stylesheet request to site request
This ensures that:

* It will load in the request for module=site.styles
  instead of the request for core, extension and skin modules.
* It will load after the 'ResourceLoaderDynamicStyles' marker
  instead of before.

Bug: T147667
Change-Id: I762a188b8ddfc192121f89ef01afaa4b5bf31b98
2017-05-01 17:27:06 -07:00
Aaron Schulz f53828bf57 Avoid wfMessage() call in Gadget cache updates
This avoids purge problems due to layered caching. The message cache
is known to take a while to regenerate and uses lockTSE=300.

Bug: T157210
Change-Id: I418e160ddb61c4d3654780f5d2bbb14bc2827e2a
2017-03-09 06:03:03 +00:00
Aaron Schulz 5fd412b41d Code style/uniformity cleanups to GadgetDefinitionNamespaceRepo
Change-Id: Ic49383ac1ef99494050005c3641aa6a758fe3e8c
2017-03-02 21:32:54 -08:00
Aaron Schulz dbccf81ffd Minor code style cleanups
Change-Id: Ia4390dcdba6fc809610b036896223448270641d6
2017-02-27 14:08:51 -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
Fomafix 75d7d07f6b Change documentation and comments from HTTP to HTTPS
This change avoids redirects from HTTP to HTTPS.

Change-Id: I2eb3b14e5bc8255f30ae557f842bfc512fc33a79
2016-12-23 18:26:43 +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
Aaron Schulz 23c0b1c14e Clean up ObjectCache calls
Change-Id: I6b741a82dca2fead8b1392208bec4303cc064d87
2016-10-11 14:20:29 -07: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
Kunal Mehta 1350d7e41b Use tabs for indenting Gadget definition pages
For consistency with rest of MediaWiki, especially CodeEditor.

Note that this will cause dirty diffs for any definition pages created
before this patch, but that's not a big deal.

Change-Id: I3ed4b4aa7d18c489b9a322f67ea6ea31e610a257
2016-05-31 00:23:12 +00:00
Kunal Mehta 3b9c177400 Bump MediaWikiGadgetsDefinitionRepo cache version
Needed by 519f30355e

Change-Id: Ic67893500f2865a46b67b701a3b418631ded5137
2015-12-08 16:21:34 -08: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
Timo Tijhof e009534e5c Remove position default logic
Follows-up 3b141e7.

See also Ib9821b7b87 in MediaWiki core.

Change-Id: If385f4c9bcf88b824099effa3c5b93545f372e82
2015-10-27 03:40:23 +00:00
Fomafix a6418d2749 Remove double whitespaces
Change-Id: Ic6c095c25b0ba80f9340254c36fc5fec911ce87d
2015-10-23 21:11:01 +00:00
Aaron Schulz 4e7612bca1 Update getWithSetCallback() callers to the newer signature
Change-Id: I4207b1acfd2e831ec13998f784833ffc413cb690
2015-10-07 19:14:56 -07: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
Kunal Mehta adcb193a1b Move GadgetResourceLoaderModule class to separate file
Change-Id: Ic7dde135168a04fc5916e5f44acd6b8639c8ce1a
2015-08-01 15:10:15 -07: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