This makes way for "MediaWiki:Gadgets/<id>.json" to be used free of
any confusion or misinterpretation about the subpage being a
translation of "MediaWiki:Gadgets".
Change-Id: Icb68ce6c26a83d7201a97a5406f8752b3c5b0855
This already returns safe Message objects, which allow Special:Gadgets
to localise it accordingly.
Avoid formatting the list ahead of time with a hardcoded user language,
and instead use Message::listParam() so that the caller controls
the Language object. This makes it safe to use in jobs, CLI, tests,
load.php and elsewhere instead of previously where RequestContext would
cause an exception or use something the caller doesn't control.
Bug: T298334
Change-Id: I77dd3c7fef86b4c8c41837bfb276b019f30baeb0
* Validate that pages have .js, .css or .json suffixes.
* Validate that namespaces are integers, disallowing doubles.
* Validate that type is either general or styles.
* Validate that targets are either desktop or mobile.
* Fix validation of skins: stop allowing `true` as it isn't actually
allowed - it causes an exception in Gadget::isSkinSupported().
Bug: T298334
Change-Id: Ic59c20172f496d281acd59419f5c760ad29ce317
The column user_properties.up_value is a text based type in all rdbms.
postgres does not autoconvert strings to numbers, so SUM( up_value )
gives an error when running on postgres.
The use of SUM( up_value ) is also problematic on mariadb/sqlite, as
up_value can be set to any number via the Action API's options module.
This value goes into the sum and produce a wrong result. Using a
non-number value allows to remove the value from the sum and that also
produce a wrong result.
Change the query to exclude the rows which disables a gadget and just
count the "active" ones. Typically there are only rows to disable a
gadget, when the gadget is marked as default, but default gadget are
displayed with the message 'gadgetusage-default' and does not needs to
be counted. In case a gadget was default in the past, there could always
such rows, so be safe and exclude them. That means it is safe to only
count for "active" gadget option usage.
This also allows to remove the up_value condition on the join to
querycachetwo as only rows to enable a gadget are now selected and get
joined to find the active users.
For the join condition use an assoc array, as for database condition the
database class is quoting the value of that array, if that is a string.
In postgres the " is used to quote columns or tables, but not values,
that gives a query error on postgres about the condition.
fixed when using the array style and not "raw" sql.
Define the condition only once as it should be the same for both
queries. Use the new IDatabase::expr function to write that sql piece.
Change-Id: I8dfc3fd5adc4c4bdabceaab20c4b37ffd48e6bee
This requires 1.42 for some new names
Changes to the use statements done automatically via script
Addition of missing use statement done manually
Change-Id: Iacbea33299995c537a7ef77b524614ad02c6a559
0c61a5a468 subtly affected the
gadget definition parsing, causing issues with definitions containing
HTML comments or certain kinds of whitespace characters. They would get
saved to the pages array with a trailing whitespace but
Gadget::getScripts() would only return pages strictly ending in `.js`.
Trimming the title before in MediaWikiGadgetsDefinitionRepo fixes the
issue.
Bug: T354385
Change-Id: Iacee432756006060217981a534434fd455285793
Remove the test that expects ES6 to fail by default, instead assert
that invalid syntax fails (as it should). Also add various other
test cases, including a commented-out test for valid ES6 by default,
to be enabled after Ie309e761f8b20640f7c0 in MediaWiki core.
Change-Id: If45856c563518255189687e3b1f620973349fb27
As this repo is not used anywhere in production, there is no backward
compatibility. Any scripts, styles, datas specified in existing
definition pages will get ignored.
Gadget::getJSON() no longer checks isPackaged() – that is now left
for callers - only relevant one is in GadgetRLModule. That was done
because validationWarnings() method needs the JSON page list even for
non-package gadgets.
Bug: T353174
Change-Id: Ic820bc4632981369c72f822fb8b9b7195930eaa6
A little efficiency to make getting from Special:GadgetUsage
to the relevant gadget files easier.
Bug: T344255
Change-Id: I0e26d10992bc3f8073bcdc8dbac86726ee6f7c36
Remove DefinitionDeletionUpdate and DefinitionSecondaryDataUpdate –
both call $repo->handlePageUpdate() which is already being called from
onPageSaveComplete/onPageDeleteComplete hooks.
The chain that made this redundant:
1. Ibe2e26d123, change hooks from hardcoded to GadgetRepo singleton.
2. Ieccc1cae8c, migrate from create-only onPageContentInsertComplete
hook to create-and-edit onPageSaveComplete hook.
3. Ib27fd34fbf, further consolidate handling of create and edit
events with handlePageUpdate, and remove any hook-level
conditionals. At this point, the DateUpdate classes became redundant.
Bug: T31272
Change-Id: I20c2759b219c80571237a73e8422f3128047eb87
* Separate out tests for MediaWikiGadgetsDefinitionRepo and
Hooks::onGetPreferences. Removed hack in fetchStructuredList() for
overriding page content for tests.
* Add tests for ES6 gadgets. For this, ResourceLoaderModuleTest is
converted back to an integration test.
* Removed createGadgetDefinitionPage() test helper method. Now using
MediaWikiIntegrationTestCase::editPage().
* Fixed GDNamespaceRepoTest failure when GDNamespaceRepo is the active
repo, by clearing WAN process cache.
Change-Id: I26b84576a91f6cb0ebae64c5fc1408666d767911
* Add tests for onBeforePageDisplay hook. A simple gadget repo
implementation, StaticGadgetRepo, is introduced for this.
* Add integrations tests for various gadget load conditions.
* Add test for onUserGetDefaultOptions hook.
* Add tests for GadgetDefinitionNamespaceRepo.
* Convert ResourceLoaderModuleTest to a unit test.
Change-Id: I275380c2bfcaa44770b3946a0a468eaaabef70c0
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
This can't do anything for two reasons:
* There are no spaces in the string after the str_replace. There is
nothing to trim.
* The regular expression above guarantees the string starts and ends
with alphanumeric characters. There can't be anything to trim, not
even underscores.
Change-Id: Iea40aafaa2457cdee9d05f105978627d38d9d5b8
* 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
Adds a "namespaces" option to the gadget definition, which takes a
list of namespace IDs. Enabled gadgets will only load when the
viewed page is in one of the required namespaces.
Bug: T204201
Bug: T63007
Change-Id: I7f797e35352b242ad78704074e98c6569a1adf91
Follows-up 087ab65e24 (Ieae6706537). To avoid silent mistakes such
as during development of T63007 (I7f797e35352b242).
Bug: T303194
Change-Id: If675f8d02ed3fee768af3d2b4912249319ae9ef4
- Always define gadget enable/disable preferences
- Show a gadget's preference when it can be enabled
Bug: T341421
Change-Id: If32eecebccf2c9b557d7dde273b7faf7118a7ac3
Easier to translate
There is no visible change on Special:ApiHelp/query+gadgets
Also split for list=gadgetcategories&gcprop=
Visible on Special:ApiHelp/query+gadgetcategories
Bug: T285545
Change-Id: Ic40326cd747ffe2153cff7d10e0083bd5e51345e
This method is possibly the main cause of DB access in non-database
tests, because it's called from the UserGetDefaultOptions hook handler,
which is triggered by most tests using UserOptionsLookup in any way.
Trying to obtain a DB connection will throw an exception in I96ecf9ff,
so just skip the lookup altogether.
Bug: T155147
Change-Id: I2ac659a472655b2a95e64dcbd3f709e465839b33