Commit graph

2321 commits

Author SHA1 Message Date
jenkins-bot f77367d6a7 Merge "Rewrite and simplify MediaWikiGadgetsDefinitionRepo cache" 2022-04-06 22:51:28 +00:00
jenkins-bot 09c2ddeaf2 Merge "GadgetRepo: Fix missing purging on delete and simplify hook handling" 2022-04-06 17:33:35 +00:00
jenkins-bot 8f6d10baae Merge "tests: Use setGroupPermissions() to fix flaky test" 2022-04-05 21:14:54 +00:00
jenkins-bot 85b37dd0b1 Merge "GadgetRepo: Add or improve type hints in various methods" 2022-04-05 21:14:52 +00:00
Timo Tijhof db04e488b6 Rewrite and simplify MediaWikiGadgetsDefinitionRepo cache
* Remove most APCu logic, including the reverse checking of WANCache
  touch time to validate the APCu key
  The APCu expiry had a 7-15s blind TTL before this check took place.
  Keep the conservative part of this (blind TTL). This should be
  more than enough to debounce memcached traffic.

* Simplify WAN handling with plain key and delete (using the default
  holdoff tombstone, which should take care of edge cases like second
  DC warming up the WAN key shortly after a delete).

* Fix incorrect method doc about being by section. The returned
  list is not by section.

Change-Id: If14ff83a29367df58d1824615bcf0bcd2edc886f
2022-04-05 21:39:45 +01: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
Timo Tijhof 6f452d11b9 tests: Use setGroupPermissions() to fix flaky test
Locally these tests are failing for me on master every time.
In WMF CI, it seems they are passing right now, although they
too would start failing as of Ib27fd34fbfe7a7. My guess is that
my change there causes the service container to be initialised
earlier and thus causes the modified global to no longer be seen.

At the very least this should have been using setMwGlobals(), which
would have also avoided the issue by ensuring a service reset,
however use setGroupPermissions() since it's tailor made for this
purpose, and avoids potential problems later with default groups
not existing.

Change-Id: I8f02ffc996d6077ca6e7433229b1ea5d8fc6ce7c
2022-04-05 21:07:28 +01:00
Timo Tijhof f0c75c4a78 GadgetRepo: Add or improve type hints in various methods
Change-Id: Ia1a3e5a69ac02822d9062262e69e6c48325c15a0
2022-04-05 20:32:16 +01:00
Translation updater bot f39529c8e7 Localisation updates from https://translatewiki.net.
Change-Id: I61baf6b5842785196e8745617b9d20f0fbfb5d35
2022-04-04 09:34:26 +02:00
gerritbot f9cd97a716 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: I2cee8a2a6af9391baba188ebb9db10ceee4a5a52
2022-04-04 01:27:06 +02:00
jenkins-bot 24a5961f0d Merge "SpecialGadgets: Avoid setting internal fields of HTMLForm" 2022-03-31 12:46:00 +00:00
jenkins-bot cc2c0b0fb8 Merge "Drop global class aliases" 2022-03-31 07:33:44 +00:00
Translation updater bot 9f089b6cbb Localisation updates from https://translatewiki.net.
Change-Id: I53a2b992d8db6c3cc55d99faa34052360aad321f
2022-03-31 08:35:54 +02:00
Reedy 85c05077e6 Drop global class aliases
Change-Id: I00c04f64e24454ba7b55d65803de64cbe90381eb
2022-03-29 20:39:19 +01:00
Translation updater bot 95a884a312 Localisation updates from https://translatewiki.net.
Change-Id: I56d303fbab92f8c27bc4c9ecda9eac541a1227a5
2022-03-28 08:21:04 +02: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
jenkins-bot f9d09841cf Merge "Use RequestContext::getActionName instead of the uncached ActionFactory::getActionName" 2022-03-26 22:15:58 +00: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
Siddharth VP 0412a47e63 Add getSkins() in GadgetResourceLoaderModule
Overrides ResourceLoaderModule#getSkins() as introduced in core
with I08a1a59b4eab90d380ca8f874, so that skin-specific gadgets are
only registered client-side if applicable to the current skin.

Bug: T236603
Depends-On: I08a1a59b4eab90d380ca8f874bb6dbba2f399590
Change-Id: I111a67c3119a294afc093b7b64bf0927a56f5b1f
2022-03-25 00:17:02 +00:00
tacsipacsi 9f14584713 Replace span.errorbox with div.mw-message-box-error
The errorbox class will soon stop working. It and its successor
mw-message-box-error were designed to work with block elements, which
meant that its inline usage caused overlaps and partially unreadable
text above/below it. To fix this, and to be able to use the
Html::errorBox function, I switched to use block elements (<div>s).
Please note that *this causes visual changes* (see screenshots on
Phabricator), and while I tried to test it locally, I might have missed
edge cases, so do tell me if it breaks something.

Bug: T304602
Change-Id: If68b934723722f976668d08a910984f89538a4f2
2022-03-24 15:35:19 +01:00
jenkins-bot 699270148c Merge "Add GadgetLoadConditions class" 2022-03-21 19:53:46 +00:00
Translation updater bot b9f07350fd Localisation updates from https://translatewiki.net.
Change-Id: I74fa3a995b1eb0c0b0a0179907fd33126cd38289
2022-03-21 08:14:47 +01:00
Siddharth VP 235820d631 Add GadgetLoadConditions class
Avoids expensive re-computations such as that of Action::getActionName, for
each gadget. It is now computed just once in the GadgetLoadConditions
constructor and stored.

This structure makes it cleaner to add more conditions down the line (such as
namespaces and content models - see T204201) and could be reused for user gadgets
(T36958).

Change-Id: I8cbc4bba4d248d9f2ff3a2836450f69970370b1a
2022-03-20 22:16:07 +05:30
Translation updater bot f5b9ef7322 Localisation updates from https://translatewiki.net.
Change-Id: I75c37596c540ea090829883442f1ab335d29e8e2
2022-03-16 08:07:40 +01:00
Alexander Vorwerk 1f40a76cc0 Bump MediaWikiGadgetsDefinitionRepo cache version
Bug: T303455
Change-Id: I32138cd8547f8c5773cbe603fdeb9826e04b0461
2022-03-09 20:32:12 +01:00
Alexander Vorwerk ba83b57d1d Bump the cache version of Gadget
Bug: T303391
Change-Id: I7f6f17de42d601e059b1b8f155a6db3dfb2c75a1
2022-03-09 14:57:57 +01:00
Reedy 998f20994c GadgetHooksTest: Use namespaced GadgetRepo
Change-Id: I6a1ba1241bd0ada4bc024c6a3f48200d9c6ae6d9
2022-03-06 02:07:17 +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
Translation updater bot 12d0780486 Localisation updates from https://translatewiki.net.
Change-Id: I5339265567f9149eaf6fb833a0975af5e70101da
2022-03-03 08:22:39 +01:00
Translation updater bot d35308558a Localisation updates from https://translatewiki.net.
Change-Id: I7297265a9ca9690342ae7802677cd5c0a57aefdf
2022-03-01 14:32:45 +01:00
Translation updater bot b725b4147b Localisation updates from https://translatewiki.net.
Change-Id: Ieb9082d17e7ef26c716512421732ed1c64cac74a
2022-02-25 09:43:46 +01:00
Translation updater bot 569b75dfc6 Localisation updates from https://translatewiki.net.
Change-Id: I11b43a68918f36b2cd6a6b78ffad8b9ffe378d47
2022-02-24 08:49:13 +01:00
Translation updater bot 035dea565d Localisation updates from https://translatewiki.net.
Change-Id: I3074d21f21ee2b047c5ec35b7dadd87f1b9ab403
2022-02-22 08:11:42 +01:00
Translation updater bot 17e2369774 Localisation updates from https://translatewiki.net.
Change-Id: Idaed0c0e108be9c9e117dc311e0977baeac74f26
2022-02-14 08:14:21 +01:00
Translation updater bot 42b985460e Localisation updates from https://translatewiki.net.
Change-Id: I27c303e502f2936b9ff785d205328af25a269888
2022-02-11 08:41:36 +01:00
Translation updater bot e489ab6982 Localisation updates from https://translatewiki.net.
Change-Id: I072b658c34180b5e2e6527ab8335391b4ced0f7f
2022-02-08 08:28:36 +01:00
Translation updater bot 65ffc6946a Localisation updates from https://translatewiki.net.
Change-Id: I93aba9c3bdd949d17d572502742115fc75deeff7
2022-02-07 08:22:07 +01:00
Translation updater bot dfe7928f4e Localisation updates from https://translatewiki.net.
Change-Id: I0149053b723ab0f9c2afa4e9f5c8719e36a81525
2022-02-03 08:44:06 +01:00
Translation updater bot 20e2ed0016 Localisation updates from https://translatewiki.net.
Change-Id: I5158740203cf4e0f65ab9fbd2d3839991de1c213
2022-02-02 08:20:03 +01:00
Translation updater bot 32cbc20b8c Localisation updates from https://translatewiki.net.
Change-Id: I56a2e3e9e1baadc12cfed58c55cc504c00bf0f32
2022-02-01 08:27:01 +01:00
Translation updater bot 6a847a1bf1 Localisation updates from https://translatewiki.net.
Change-Id: Ic6e79aac0ef2d4121b833cad5dd3d1b44149049d
2022-01-31 08:22:04 +01:00
Translation updater bot f86502f292 Localisation updates from https://translatewiki.net.
Change-Id: I587f0ed6b35b2be6d80bcd70684e0ba62729c92d
2022-01-27 08:38:46 +01:00
jenkins-bot f238e6d4e1 Merge "Avoid validating gadget definition content multiple times on save" 2022-01-26 18:24:44 +00:00
Siddharth VP bded600e36 Avoid validating gadget definition content multiple times on save
The validation appears to be occurring 4 times:
1. JsonContentHandler->preSaveTransform --> GadgetDefinitionContent->isValid
2. GadgetHooks::onEditFilterMergedContent --> GadgetDefinitionContent->validate
3. ContentHandler->validateSave --> GadgetDefinitionContent->isValid
4. RevisionStore->checkContent ---> GadgetDefinitionContent->isValid

Caching the validation result reduces it down to 2.

(Validation in GadgetHooks::onEditFilterMergedContent is to provide a more useful error message than what ContentHandler gives – which is just "Invalid content data".)

Change-Id: I026751b7e9b111b4f0bb9ab5fa0e9737a0385b07
2022-01-26 15:39:14 +05:30
Translation updater bot 0f0688ebf2 Localisation updates from https://translatewiki.net.
Change-Id: I2468ba1d2c3b606ab0e131fb4284ef12d3d65b1c
2022-01-26 08:25:02 +01:00
Translation updater bot 36a19b1613 Localisation updates from https://translatewiki.net.
Change-Id: I301170495b9898ce04cccac45f67e80ff49fcaa9
2022-01-25 08:32:41 +01:00
Translation updater bot 0a7aeb655a Localisation updates from https://translatewiki.net.
Change-Id: Ife73c783a439fa4d01f2dd11821b4804922a78eb
2022-01-24 08:27:14 +01:00
jenkins-bot de2ed9219f Merge "Restrict ?withgadget query parameter to opt-in gadgets." 2022-01-24 00:46:10 +00:00
Ammarpad 5d3a547c8b Restrict ?withgadget query parameter to opt-in gadgets.
?withgadget query parameters allows for ad-hoc loading of gadgets
(after passing all other basic checks). This was recently added in
I5b30d4e.

In T29766#7611796 Gergo raised concerns about how this can be
potentially abused.

This patch aims to restrict the feature by giving gadgets latitude
to either use it or not depending on the nature of the gadget.

The patch does so by adding `supportsUrlLoad` option that gadgets
(maybe those deemed safe) can use it to opt-in to the parameter.
By default gadgets don't support it, so it can be enabled for each
on a case-by-case basis.

Bug: T29766
Change-Id: Ie64174085e650579d76cc862774a4fe1b3d08396
2022-01-24 00:31:19 +00:00