With GadgetDefinitionNamespaceRepo, there should be separate rights for
editing gadget json as opposed to editing gadget css/js, so that admins
can be granted the former, while the latter remains restricted to
int-admins.
Reusing the MW core rights for site CSS/JS/JSON seems to make the most
sense here. Protection is now applied via GetUserPermissionsErrors hook
rather than as namespace protection.
For editing any non-CSS/JS/JSON pages in the namespace, editsitejs right
is required.
Bug: T298834
Change-Id: I6ffd5e9467774f1e79ccdce8b6b4739f07be2da8
… e.g. using modern syntax, or avoiding unnecessarily complex
language features. For example, we don't need to call count() when
all we care about is the boolean "is empty/not empty" information.
Change-Id: I13ae802f64627a79b29d1e57ad71486cb2fb977f
* A fixed license header for the file.
* Move class descriptions, doc tags, author/copyright to the
class block. Remove MW-core specific "ingroup" tags such as
"SpecialPage" which has no meaning in an extension and are not
used by Doxygen.
Ref https://gerrit.wikimedia.org/r/q/message:ingroup
Change-Id: I13d9b0ff7a3150180196c9fa58f8a321b14edd22
- Always define gadget enable/disable preferences
- Show a gadget's preference when it can be enabled
Bug: T341421
Change-Id: If32eecebccf2c9b557d7dde273b7faf7118a7ac3
The ResourceLoader module associated with the gadget will have
mobile and desktop targets, but this allows gadgets to disable
themselves on the mobile site if necessary by not adding the gadget
to the page if it's been marked as such.
This also has the benefit of not showing the gadget on the preferences
page if it's not relevant.
Bug: T328610
Change-Id: I4f2b57d1d22f641ff7520358a46cd0e6b2103aa9
Added PreferencesGetIconHook to add an icon on the Special:Preferences section.
Bug: T317419
Depends-On: I6d5730d47e7595b1705787995fe5db2fe734d7f5
Change-Id: Ie2505622680573dfe9e50b48976c986cf2512097
== 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
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