Commit graph

46 commits

Author SHA1 Message Date
Fomafix 85351609fd Use classic hook for CodeEditorGetPageLanguage
This hook needs the old call structur as there is not a interface for
it.

When CodeEditor extension is changed to provide that interface, this
needs to be moved to another class, because the extension is optional
and the interface not loaded on all installs.

This change is a follow-up to b504a6f496
and reverts the change for hook CodeEditorGetPageLanguage because
onCodeEditorGetPageLanguage is still a static function.

Bug: T271014
Change-Id: I0ac6f353be099c4c9b4cb36b65cb463b7b7b89ea
2022-04-19 13:42:45 +00:00
Fomafix b504a6f496 Use HookHandlers and implement hook interfaces
Bug: T271014
Change-Id: I50d42df04038d1214fd9835c3d3b0f602037ac62
2022-04-17 12:00:24 +00:00
jenkins-bot 09c2ddeaf2 Merge "GadgetRepo: Fix missing purging on delete and simplify hook handling" 2022-04-06 17:33:35 +00:00
Timo Tijhof ab753d805e GadgetRepo: Fix missing purging on delete and simplify hook handling
== Motivation ==

On a local dev wiki and in CI, where no gadgets are defined yet,
fetchStructuredList() is called on every load.php request and doing
uncached database look ups. This is because T39228 (stale cache
after Gadgets-definition was empty or created) was fixed by disabling
the cache until the page exists. This seems like a poor solution,
and commit I3092bcb162d032 recognises that the problem was not
understood at the time. I propose to instead cache it always and
purge it when the page is modified in any way.

Cold calling fetchStructuredList() accounted for ~170ms of ~400ms
when trying out debug v2 (T85805), thus making it significantly
slower and causing a chain of dozens of requests to pile up.

== Previously ==

* Legacy repo (MediaWikiGadgetsDefinitionRepo) only implemented
  handlePageUpdate.
* handlePageUpdate was called from onPageSaveComplete for both
  any page edit, and for creations in the experimental namespace.
* The experimental GadgetDefinitionNamespaceRepo is based on
  ContentHandler rather than global hooks. This system does not
  have a create-specific callback. It called update for edit/create,
  and delete for delete. The experimental repo relied on create being
  called from the global hook for the legacy repo, and update was
  then called twice.
* There was no global hook for onPageDeleteComplete, thus the
  legacy repo did not get purges.

== Changes ==

* Add onPageDeleteComplete hook to fix purges after deletion,
  with the legacy repo now implementing handlePageDeletion() and doing
  the same as handlePageUpdate().

* Fix handlePageUpdate() docs to reflect that it covers page create,
  since onPageSaveComplete() called it either way.

* Fix experimental repo to include its namespace purge in
  its handlePageUpdate() method.

* Get rid of now-redundant handlePageCreation().

* Get rid of handlePageDeletion() since its implementations would
  now be identical to handlePageUpdate().

  All these hooks and handle*() methods are just for a memc key
  holding gadget metadata. We don't need to microoptimise this
  on a per-page basis. Gadget edits are rare enough that purging them
  as a whole each time is fine. We do the same in MediaWiki core
  with ResourceLoaderGadgetsModule already.

Bug: T85805
Change-Id: Ib27fd34fbfe7a75c851602c8a93a2e3e1f2c38a0
2022-04-05 21:39:45 +01:00
jenkins-bot 24a5961f0d Merge "SpecialGadgets: Avoid setting internal fields of HTMLForm" 2022-03-31 12:46:00 +00:00
Reedy 85c05077e6 Drop global class aliases
Change-Id: I00c04f64e24454ba7b55d65803de64cbe90381eb
2022-03-29 20:39:19 +01:00
Func 3c23c202e5 SpecialGadgets: Avoid setting internal fields of HTMLForm
HTMLForm would handle title itself, don't need to set it manually here.

Depends-On: Iaec81a2fb49162f2fc764f143f88e887572a3a0b
Change-Id: I4a9788e853463e51570ba7c04a8bd40f1ed95cfa
2022-03-27 13:33:38 +08:00
Siddharth VP cb6f69103c Use RequestContext::getActionName instead of the uncached ActionFactory::getActionName
Also avoids injecting the ActionFactory service.

Change-Id: I9a26aff0d3885470d6cd376ab870023bb377ac77
2022-03-26 22:00:01 +00:00
Reedy 2952dadb9f Add global class_alias for Gadget
Used for serialization purposes...

Change-Id: I3345ad668aa55596bc9ec18b56d9891f10bb0285
2022-03-06 01:50:36 +00:00
Reedy 01f6a6c34e Namespace extension
Bug: T278278
Change-Id: I49b57e68079c998419e235b1727eea8c121c234b
2022-03-05 17:03:35 +00:00
Kunal Mehta 44d3602898 Link entries on Gadget definition pages
Links the following entries in gadget definitions to the associated page:
- scripts
- styles
- datas
- peers
- dependencies (only when they are also a gadget)
- category (links to MW message page)
- messages

unserialize(serialize()) hack is a bit ugly, but it works.

Co-Authored-By: Siddharth VP <siddharthvp@gmail.com>
Bug: T298844
Change-Id: I9154f600997fe693410e7560ed30732102b806aa
2022-01-12 19:33:04 +05:30
Siddharth VP 1f7b9d90df Support JSON files in gadgets
The parsed content of JSON files in the gadget is made available from the
gadget's JS files via require(). That is, MediaWiki:Gadget-data.json (or
Gadget:data.json) is available as `require('./data.json')`. This is
supported for both MediaWikiGadgetsDefinitionRepo and
GadgetDefinitionNamespaceRepo. The JSON parsing is done server-side.

JSON can only be used in "package" gadgets - in which the JS files can
also be invoked via require().

Also added a test for GadgetResourceLoaderModule.

Bug: T198758
Depends-On: Ib4556d09c4d393269e32771aab00f59a5f630e1b
Depends-On: Id4589a597ccfc4266b3e63d10f75b146aa7a287a
Change-Id: I21acb46cdd244a39b5cc6963aa763f0113bd1e38
2021-12-27 17:33:21 +00:00
Bartosz Dziewoński ea786ce9dc Re-apply "Make each gadget a separate preference, instead of one huge multiselect"
Previously attempted in 82281d82d0,
reverted in 7c4ac597e2.

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: Ie96fd94c994d05ab8507920fa560c7ed9c1f9b69
2021-11-05 23:15:45 +01:00
Krinkle 7c4ac597e2 Revert "Make each gadget a separate preference, instead of one huge multiselect"
This reverts commit 82281d82d0.

Bug: T126962
Bug: T292777
Change-Id: I7c858b8c4bc12626ea1d53374ea4d75862f684ff
2021-10-07 19:52:18 +00:00
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
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
James D. Forrester c5dddba954 Drop MW <= 1.34 compatibility
As a Wikimedia-deployed extension, we don't keep B/C for older MW branches,
instead people should use the release branches.

Change-Id: I8b8e554a8a8663c19ce3ea52f047c8d40537b042
2021-03-24 14:22:11 -07:00
DannyS712 f5ecc23c17 Update hooks to use PageSaveComplete hook in MW 1.35+
Bug: T250566
Change-Id: Ieccc1cae8c4b53a582391066a1a6336eae6c9277
2020-06-25 22:50:05 +00:00
Reedy 2447093b7a Convert to manifest_version 2
Bug: T252470
Change-Id: I5275e8317013ef1b17fc29a6aeca9644e5a5a839
2020-05-12 01:52:38 +01:00
DannyS712 a7f35df800 extension.json - don't use array for hooks with one handler
Change-Id: Ic1ba01c4734a6235a38fb45db85b463d0d724e4d
2020-03-01 08:43:19 +00:00
zoranzoki21 53de932571 Move all apihelp translatable messages to separate files
Bug: T189982
Change-Id: Ifc682634d8403401e2ca4667e34474ed08574f53
2019-01-29 17:11:32 +00:00
James D. Forrester ee4973ebfa Mark MediaWiki:Gadgets-definition as a raw HTML message
Bug: T200997
Depends-On: Ib16db04e499ad28216ee08b8cccccf3f141e2bad
Change-Id: I4a01bfb6f89c0f4e137feda7cf5551f970fc6905
2018-08-27 10:38:31 -07:00
Fomafix b6e7bcf015 Use ContentLanguage service instead of global $wgContLang
This change raises MediaWiki version requirement to 1.32.

Change-Id: Ieffed829bf5a8e1f138fd5f63518e415cebb1287
Depends-On: I193f5b9a95430b0a05573c361715e053e5411e32
2018-08-05 00:52:53 +02:00
Sam Wilson 97c5bd7732 Prevent gadget preferences from being cleaned up
Bug: T188966
Change-Id: I5627f014827fdbf266eb7fdb00a446f81a0c3458
2018-04-06 20:06:11 +00:00
Kunal Mehta 677d4e932c Move classes into includes/
Change-Id: I10bc5234ad2ebeed2514aafc3dbe2a0afa983bd8
2018-02-25 11:19:23 +00:00
Kunal Mehta f04d09e0d9 Use SPDX 3.0 license identifier
SPDX released version 3 of their license list (<https://spdx.org/licenses/>),
which changed the FSF licenses to explicitly end in -only or -or-later
instead of relying on an easy to miss + symbol.

Bug: T183858
Change-Id: I94d4d2b21bdbbc12e1a34c1373a631e03ac2df93
2018-01-31 23:05:41 -08:00
Matěj Suchánek 1d60e9f74f Replace Linker::link() with LinkRenderer
This raises MediaWiki version requirement to 1.28.0.

Bug: T149346
Change-Id: I90117382215c0e7962f2d4a4fa275898beab9816
2017-03-18 09:14:45 +00:00
Reedy 7c922c92b9 Replace ArticleSaveComplete hook usage
Bug: T147556
Change-Id: I6f3a58c8e7cf1382fc8e1ac30cc697deb7fc9eb7
2016-10-06 17:16:15 +01: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
niharika29 75ae3558e7 Add a feature flag to turn off the 'active users' query on GadgetUsage
Currently takes >24 hours to complete on enwiki and thus isn't run
at all. Need a better optimised query. Until that happens, we can
turn it off on enwiki.

Bug: T121484
Change-Id: Idcf2a8a1cdf5ce4c2f6a631ef980be5a48ca547b
2015-12-18 19:30:45 +00: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
niharika29 be8091a288 Add a special page to show number of users for each gadget on the wiki
Bug: T115152
Change-Id: Id1e245f8fdb2fc6a764682ae34937f35af24bd7c
2015-10-23 15:02:23 +00:00
Southparkfan dbecdaee62 chmod 644 for php and json files
Bug: T111743
Change-Id: I3ebc7c05f4a598a702cbd2948147dade3323e994
2015-09-08 18:06:35 +02:00
Kunal Mehta e6b8b57d9b Set up "Gadget" and "Gadget definition" namespaces
Register the "Gadget", "Gadget definition", and their respective talk
namespaces. It will not be possible to create any pages in the Gadget
and Gadget definition namespaces due to the "gadgets-edit" and "gadgets-
definition-edit" rights not being granted to any groups.

Depends on Iaf8b44d02adf9 in MediaWiki core.

Change-Id: Ia88c774cc0decc252a4a4277d14822048db95801
2015-08-08 01:39:56 -07:00
Kunal Mehta 3d270b36bf Remove ConfigRegistry entry for gadgets
It no longer has any configuration settings, so it doesn't need to
registery a Config type.

Change-Id: Icd0f759ca4e58b1436bfcd2403a38e1691d3bc39
2015-08-01 15:10:20 -07: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
Aaron Schulz 2bd2ef99c5 Removed caching config variables and always enable caching
* APC will be used if around as a tier 1 cache
* This also makes it easier to have mixed zend/hhvm servers

Bug: T106743
Change-Id: Ie9f234753f78215441474dddc4eadedbd2b76ad7
2015-07-23 15:26:06 -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
Kunal Mehta 2c03c5203e Set manifest_version in extension.json
Bug: T100745
Change-Id: I9b0e0b774be8396399043109d68b1e1294ced9a7
2015-05-28 20:39:10 -07:00
umherirrender 6c25618f55 Replace deprecated $wgSpecialPageGroups
$wgSpecialPageGroups is deprecated since 1.21
override SpecialPage::getGroupName instead

Change-Id: I3fe4906a422fdf7f6d8ba51b39b7f45c01c3d772
2015-05-15 21:55:50 +02:00
Ori Livneh ba1311c323 Make the ObjectCache implementation used for Gadget def's configurable
Add a configuration option, 'GadgetsCacheType', which may be used to specify
the ObjectCache type to use for gadget definitions.

Change-Id: I1e02f7b6c470c5fffa014c6247c71f43a69420b6
2015-05-11 18:17:36 -07:00
Kunal Mehta 083aea8580 Remove unused i18n shim
Change-Id: I3fa71465277a3119c5deca86668a0128ac78caba
2015-05-01 21:58:14 -07:00
paladox f9a55554ee Add extension.json, empty PHP entry point
Bug: T87918
Change-Id: Iacd056781823bd73144c5fa09cd884ee8e9cf0d4
2015-05-01 21:56:54 -07:00