Commit graph

214 commits

Author SHA1 Message Date
Siddharth VP 43efda4f96 Avoid adding hidden gadgets in default options
Hidden gadgets do not have associated user preferences. Adding them to $defaultOptions only causes them to be unnecessarily exported in mw.user.options.

Bug: T299071
Change-Id: Ic55e7f2a9daa405cddd0189de3d32f5825bc336a
2022-01-14 09:23:30 +05:30
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
Gergő Tisza 6b74e170c0
Add edit link to gadget definition in Special:Gadgets
When using the Gadget definition: namespace, link to the definition
pages from Special:Gadgets. Also change the wording of the links
to edit the names of the gadgets, to disambiguate them.

Change-Id: I327a4cfa9846edec60e1aaafc674cd66f4e0beae
2021-12-31 20:42:37 -08:00
Siddharth VP 7ead5dab61 Allow specifying page actions in definitions
Allow specifying page actions ('view', 'edit', 'history', etc) in
gadget definitions. If specified, the gadget is run only on the given
page action(s).

This is especially useful for default gadgets like RefToolbar[1] and
TextReactions[2] that only need to be loaded while editing.

[1]: https://en.wikipedia.org/wiki/WP:RefToolbar
[2]: https://en.wikipedia.org/wiki/WP:Text_reactions

Bug: T204201
Bug: T63007
Change-Id: Idde71b3f1f6c36cd21539a2312be8f12217a9acc
2022-01-01 00:41:08 +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
jenkins-bot 0010b1802b Merge "Add global 'withgadget' query parameter for ad-hoc loading of gadgets" 2021-12-15 07:47:25 +00:00
vladshapik b3524efe41 Avoid using User::getOption
Remove using of User:getOption since this method
will be hard-deprecated. Now it is soft-deprecated.

Bug: T296083
Change-Id: I140cbd5655ac4ae0ad7b6d30c5e6bae0008aba07
2021-11-26 12:27:39 +01: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
Siddharth VP 14af941e88 Add global 'withgadget' query parameter for ad-hoc loading of gadgets
When viewing pages, the 'withgadget=' query parameter can be used in
the URL to load a gadget that isn't enabled by the user's preferences.

The gadget is only loaded if all other conditions are still satisfied
(supported skin, supported targets, required user rights).

Bug: T29766
Change-Id: I5b30d4e0010561685eef661a515e2892045bb776
2021-10-16 03:14:34 +00:00
Reedy 32677ff590 Various code cleanup
Change-Id: I59b7ac50b621df1da402752327841743141944e3
2021-10-09 01:34:45 +01:00
jenkins-bot 669b351241 Merge "Override ContentHandler::fillParserOutput instead of Content::fillParserOutput." 2021-10-08 14:32:36 +00:00
jenkins-bot 0a55c5f0f9 Merge "Revert "Make each gadget a separate preference, instead of one huge multiselect"" 2021-10-07 20:11:30 +00: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
Roman Stolar cbad567396 Override ContentHandler::fillParserOutput instead of Content::fillParserOutput.
Prepare override for GadgetDefinitionContentHandler, remove usage in GadgetDefinitionContent.

Bug: T287158
Change-Id: Icc3fa02f7089eaccd2dad8ff28f3db8cbf8eac03
2021-10-07 13:09:05 +03:00
jenkins-bot 1d3af2d82b Merge "Add all gadgets to DefaultUserOptions" 2021-10-06 23:59:58 +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 d175e964db Add all gadgets to DefaultUserOptions
Without the default the preference is never deleted from the database,
even it was disabled by the user.

Bug: T291748
Change-Id: I1010e260fda118cbea83ad39e33055e403e37630
2021-09-29 08:19:16 +00:00
Jayprakash12345 1472a2733c Use getText() instead of getNativeData()
Bug: T283673
Bug: T155582
Change-Id: Iaf8a0ded40e3303d6fbcfac022b1461c4d2b1333
2021-08-04 02:43:36 +00:00
Roman Stolar ffa6b4de09 Override ContentHandler::getDeletionUpdates and ContentHandler::getSecondaryDataUpdates.
Use it instead of Content::getDeletionUpdates and Content::getSecondaryDataUpdates.

Bug: T285730
Bug: T285729
Change-Id: Ie4ea0917f120809be59e2b7afad51cd189d64dd1
2021-07-16 12:46:41 +02:00
jenkins-bot d18d79ac7f Merge "Handle EditFilterMergedContent hook properly to display error message" 2021-06-26 12:00:21 +00: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
Umherirrender 6132dbae64 Remove PHP 5.3 $this closure workaround
Change-Id: Ib1f2808a9e0d9c93b2b598fd07e0f2a61c122f2a
2021-05-15 01:57:51 +02:00
jenkins-bot 0c5539d437 Merge "Do not use SpecialPage::getConfig in constructor on Special:GadgetUsage" 2021-05-04 20:50:02 +00:00
libraryupgrader c3c98c1146 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I5e0b9e78f0436355cc21dc356fb78e96e59cb536
2021-05-04 18:43:54 +00:00
Umherirrender b0cc049a4f Do not use SpecialPage::getConfig in constructor on Special:GadgetUsage
The context source is not set at this point and the global request is
used and logged:
SpecialPage::getContext called and $mContext is null. Using
RequestContext::getMain(); for sanity

Change-Id: I50f96f8e6517ec7221c4b82872208787af63e12b
2021-04-30 16:28:20 +00:00
Func fb7ac5619b Handle EditFilterMergedContent hook properly to display error message
On mediawiki version 1.36 and before, just returning false in this hook can't display error message by default.
Set $status->value manually still to provide backward compatibility.

Bug: T280312
Change-Id: Ic80fd227668794c21299a3f7879f61a20a2f55bd
2021-04-24 01:52:58 +00:00
Jforrester b50309db2c Revert "Reduce message parse in GadgetHooks::getPreferences"
This reverts commit 662c63882c.

Reason for revert: plain() is too plain for our needs, sadly.

Change-Id: I1cf3c7c61e9e90567587350639590691add1af34
2021-04-21 21:55:32 +00:00
Umherirrender 662c63882c Reduce message parse in GadgetHooks::getPreferences
Multiselect can build by message keys only

This reverts fix for T32182, there is no way to handle the dir on each
item/checkbox at the moment

Bug: T58633
Bug: T278650
Depends-On: Ie983757081dc39f3685ba5b01b02bd124880e1af
Change-Id: Iccd6202c443bd699aa3a911c8ba36a2b7bcdcfed
2021-04-20 18:49:19 +00:00
Umherirrender ab552f3e2d Use ::class for class name
Change-Id: I31900653180fa9667ac119fefaf1ea1c33aa2c83
2021-04-08 20:34:17 +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
sahil 5ceabd7219 Fixed typo "paramaters"
Changed from paramaters to parameters in extensions / Gadgets

Bug: T201491
Change-Id: Ib5e85d64796d70cf58a068116e211e3c1c73470d
2021-03-10 22:24:24 +05:30
Petr Pchelko 7f124b8874 Don't pass empty permissions to Authority::isAllowed
Bug: T271459
Change-Id: Iebf2dca34eea751391d9740443c195287399aa5c
2021-01-19 15:15:45 -06:00
Umherirrender 4de4305c6c Add missing @var and improve documentation
Change-Id: Ib258665c3fe76eeadd32f949fe01d88e6f2fd70d
2020-12-18 00:21:49 +01:00
libraryupgrader 5fc41bb340 build: Updating mediawiki/mediawiki-codesniffer to 32.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam
* MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate
* MediaWiki.Commenting.PropertyDocumentation.MissingVar
* MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage

Additional changes:
* Dropped .inc files from .phpcs.xml (T200956).
* Added the `wikimedia/mediawiki` profile in .eslintrc.json (T262222).

Change-Id: I73a5f722738dff75c623cf631bfa7e3dcf8d6f82
2020-10-29 13:34:25 +00:00
zoranzoki21 a66f0f7baa Fix MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
In ApiQueryGadgetCategories.php for function getList() I've added inline comment for ignoring this rule, because is unclear why it throws this error.

Change-Id: I74c4a6c75f48b8f7a237396666db3b37993c300d
2020-10-12 15:26:23 +00:00
zoranzoki21 bc5b58d736 Fix MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected
Change-Id: I26209fd4fd44917733e2b34e34dea31ec0d95341
2020-10-12 11:10:15 +02:00
Ammar Abdulhamid 146545919d Remove usage of Skin::getSkinNames()
Bug: T257993
Change-Id: Icc945ce1e3287a3b25152702818e5b2a90232677
2020-08-26 07:54:17 +01: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 3ce0a0fb38 Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: I17a7f0195dd0a419ae8afe46521dd8f061ba53c6
2020-05-20 00:13:16 +00:00
DannyS712 3f00fbb5aa Remove use of Revision::newFromTitle
Bug: T249183
Change-Id: Ibfcb8d7e56f559f3fb5179bac4dfeade8da22533
2020-04-08 12:44:29 +00:00
libraryupgrader 2abdd0f983 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Additional changes:
* Added .eslintcache to .gitignore.

Add an explicit check before using the parameter.

Depends-On: I92ecaa9c14e5c8ba32d152a9e2246a2144b1c7da
Change-Id: I255237574e76f1c0d92f376bc8cbb81f7cb4ed14
2019-12-21 14:01:00 +01:00
Umherirrender 7c13328467 build: Updating mediawiki/mediawiki-phan-config to 0.8.0
Argument 1 ($min) is 7000000.0 but \mt_rand() takes int
Argument 2 ($max) is 15000000.0 but \mt_rand() takes int

Bug: T235049
Change-Id: I2d7d0d6defd312dbed0de833678f3768fa3d7a46
2019-11-03 12:13:20 +01:00
Umherirrender db80002484 phan: Remove suppression for PhanParamTooMany
Depends-On: Id66af5c3de3e5bc5c2909316e1984eae95a0012a
Change-Id: I49daa6ec7d58d2e5b9882025f5c68552c6537567
2019-10-04 11:46:21 +02:00
Derk-Jan Hartman 2008def806 Only queue gadget module if relevant on the current target
Bug: T171180
Depends-On: Ibe693bb6a84bdf56fd22d1ea1f0b798094b91c62
Change-Id: Ibce4d642c87651880f3c981dfa0d68def3bddd3a
2019-10-02 19:43:15 +00:00
jenkins-bot 9d4d4b0a67 Merge "Hook handlers don't always need to return something" 2019-07-26 15:09:44 +00:00
Max Semenik 2470a59218 Hook handlers don't always need to return something
And other minor fixes to hook signatures.

Change-Id: Ib6d8c9dff5bb79386ac88828ba2a57a9bf81ee71
2019-07-23 02:23:27 -07:00
DannyS712 bbdc32d8d6 Add help links to special pages
Bug: T228071
Change-Id: I1bfa452ed21db5f6edc8971390b407e57e7e015d
2019-07-18 01:35:23 +00:00
jenkins-bot 1564077b1f Merge "Preload tablesorter styles by module 'jquery.tablesorter.styles'" 2019-06-11 20:19:19 +00:00
Thiemo Kreuz 62f3d828b8 Update some generic/unspecific PHPDoc type hints
Change-Id: I30ad46cc9d503b4403dd2e0ab263d0db2039a8e3
2019-06-04 17:33:17 +02:00
Kunal Mehta b28ad14b8c Upgrade to newer phan
Bug: T216919
Change-Id: I3a403891eafa703215a79526fcf9469b1fd6edc6
2019-03-17 16:39:02 -07:00
Max Semenik 963f3c1525 Don't use deprecated Sanitizer::escapeId()
Change-Id: Ia92e685d33e377669b034b02819e183efe77e4f2
2019-02-22 12:26:17 -08:00
Fomafix ef2197f713 Preload tablesorter styles by module 'jquery.tablesorter.styles'
This change avoids the flash of missing sorting buttons while loading,
but only with I0b446d18f47428d8c0c4aed78b75de16fe106218 in MediaWiki
core included in MediaWiki 1.33 or higher.

Depends-On: I0b446d18f47428d8c0c4aed78b75de16fe106218
Change-Id: I6efb7a995589a7b93691d5ebd37ae8ac42f0a971
2019-02-02 17:10:32 +01:00
Fomafix be4e6db51d SpecialGadgetUsage: Add Infinity as sort-value for defaults
This change ensures that gadgets that are enabled by default are sorted
with a higher value than the other gadgets.

Change-Id: I02fab73c85b4c3580e484832c91a7314c797e978
2019-01-22 04:58:39 +00:00
Fomafix 49ec533e8d Fix typo in comment
This typo was introduced in 88d0b223.

Change-Id: Ib9adde89ccc1fca6bac0ceb5ba409637a03f7dd7
2019-01-04 23:11:51 +01:00
Umherirrender 6b2e46b142 Declare visibility on SpecialGadgetUsage::__construct
Change-Id: Id98c214770224e6d5b65e1c164a6663e09861a0f
2018-10-31 23:18:47 +01:00
Aaron Schulz 1204d238f0 Increase loadGadgets() expiry to 15 seconds to avoid stampedes
Bug: T203786
Change-Id: If45b91987f3f523139e5e66f546be17a455647fe
2018-10-30 15:55:51 +00:00
Aaron Schulz 1acde38a6a Randomized APC gadget definition refreshes to avoid stampedes to memcached
Bug: T203786
Change-Id: If87e752f5cdc6bd216ad96486a86a40b2477b315
2018-10-19 01:57:07 +00:00
Aaron Schulz 93137ec581 Clean up gadget definition key code
Change-Id: Ic3116de9f5b76375c908f540a29945203f14d4c5
2018-10-05 03:29:29 -07:00
Umherirrender c8b50c30ee Fix caller name in GadgetDefinitionNamespaceRepo::getGadgetIds
Seeing {closure} in the logs as caller is not helpful

Change-Id: I1bfefd86aa0929ddafff3ccbdf50730a22fcdcb4
2018-09-30 13:47:56 +02:00
Timo Tijhof 848775d925 SpecialGadgets: Restore line breaks between actions and uses
Follows-up f3da602. I accidentally removed the first of the
line breaks.

Bug: T204616
Change-Id: I53b43acb5c0d43443b2f62bd335fc013d2e23539
2018-09-26 03:46:10 +01:00
Timo Tijhof f3da602058 SpecialGadgets: Omit blank space due to <br> between <ul> and <p>
Due to some of the portions of the gadget list items being optional
it's not consistent whether or not they should be separated by
a line break.

When two pieces of text follow each other, there should be a line
break in-between.

When a piece of text is output afte a list, however, there is no
need for a line break as anything after a list would already
become its own line. Printing one anyway causes a blank space
to show up, which visually causes it to appear related to the
next gadget.

Fix by setting a boolean after each portion to indicate whether
or not it should be followed by a line break.

Also improve the code a bit with comments and use Html instead
of Xml.

Bug: T204616
Change-Id: If65e170746898999dd8f5351004eeaf49b340ab2
2018-09-17 23:33:35 +01:00
Timo Tijhof e369419bdd SpecialGadgets: List right names instead of descriptions
The lengthy and localised descriptions make it hard to scan and
identify the actual rights themselves. They are meant as descriptions
to explain what a right is, not to identify the right itself.

It should probably be more similar to the list of checkboxes
on Special:UserRights. For now, kept the descriptions as tooltips,
but could also remove them entirely.

Change-Id: I29f68ffd5a8d002b65384f3762fb9e5631c13def
2018-09-17 23:17:44 +01:00
Bartosz Dziewoński 52d57c6597 Avoid 'rawrow' for HTMLForm 'info' fields
The wrapper tags that we have to create when using the 'rawrow' option
would have to be different for OOUI and non-OOUI preferences forms,
making it impossible to support both at the same time.

We used it in order to generate `<td colspan=2>...</td>` rather than
`<td></td><td>...</td>`, and make the description span both the label
and the input columns. However, this is not necessary, because the
label column is entirely hidden on this page of preferences, as all of
the preferences have no labels.

Bug: T203202
Change-Id: Ib9510a8bfb2430fdda3988d88628c9f0c509c6d0
2018-09-03 18:19:34 +02:00
Thiemo Kreuz 01a3de04e7 Remove not needed properties from "info" form field
* "raw" and "rawrow" are documented as booleans.
* "raw" does not have any effect if "rawrow" is set.
* "label" does not have any effect if "rawrow" is set.
* "noglobal" refers to GlobalPreferences. It does not have any effect
  because "info" fields are blacklisted anyway.

https://github.com/wikimedia/mediawiki-extensions-GlobalPreferences/blob/master/includes/GlobalPreferencesFactory.php#L75

Also see my longer comment in I1ab2bc6 where I explain all these changes.

Change-Id: I7b4e08b45070ae07935e1cd59091b3d608583e5b
2018-08-20 14:41:35 +00:00
jenkins-bot a6c181e610 Merge "SpecialGadgetUsage: Add <thead> and <tbody> in the table" 2018-08-15 05:00:22 +00:00
jenkins-bot 7fddd2bdc7 Merge "Use ContentLanguage service instead of global $wgContLang" 2018-08-12 04:56:26 +00:00
Derk-Jan Hartman 9e24c3a551 RL: Simplify userrights check of Gadgets
Change-Id: I135dcfdba72014803b8ce9710680fb5574f76d04
2018-08-08 13:46:24 +00: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
jenkins-bot ef4c537d9e Merge "Fix skins option to use currently displayed skin, rather than user preference" 2018-08-03 18:53:39 +00:00
Matt Russell b340532c52 Fix skins option to use currently displayed skin, rather than user preference
The user's preference usually reflects the displayed skin, however this isn't
true if the `useskin` URL query is set, or MobileFrontend is being used.

This fixes gadgets being displayed on the wrong skin when using `useskin`,
and allows mobile-specific gadgets (using `skins=minerva`).

Testing if the gadget is allowed in the current skin is split out from
`isAllowed` to `isSkinSupported` to enable a future patch showing gadgets
on preferences regardless of if they are allowed on the current skin.
Test coverage is added for both functions.

Also fixed another test which wasn't working, presumably because the placeholder
user didn't have the "read" right, so the section wasn't being kept.

Bug: T199478
Change-Id: I21febe92d54d6d0b89925f902581cc2739d824fb
2018-08-01 11:06:17 +10:00
Fomafix 3aeffaa12b SpecialGadgetUsage: Add <thead> and <tbody> in the table
Change-Id: I53f61ce4c7d0721171a455e25b560ce33d4109b9
2018-07-30 21:38:20 +02:00
Fomafix 98ac345756 Use $lang->equals() to compare Language objects
Change-Id: Iae691c2b1e4f34bb0f509a109333277ade900659
2018-07-30 20:01:18 +02:00
libraryupgrader 33ecce01c0 build: Updating mediawiki/mediawiki-codesniffer to 20.0.0
Change-Id: I210883a100f2060e9bff0d5066896ce35b45a788
2018-05-26 03:01:39 +00:00
Kunal Mehta c383794d16 Fix variable name reuse in EditFilterMergedContent hook
Bug: T194695
Change-Id: Ic99e35874f1a3a4a7c1d1c302294bbecd23080ed
2018-05-14 17:11:58 -07:00
Jayprakash12345 54d1eb0d77 Convert Special:Gadgets/export/$par to use OOUI
Bug: T191822
Change-Id: Ia59918a1a7f10d56a5c32050591a537d90c6de7c
2018-04-09 23:20:17 +05:30
jenkins-bot 435d0f4fcd Merge "Use SPDX license identifiers for @license" 2018-04-07 21:06:34 +00:00
jenkins-bot 4ca18e2fac Merge "Change ResultWrapper to IResultWrapper in special page" 2018-04-07 21:06:33 +00:00
Kunal Mehta bb81950e9f Use SPDX license identifiers for @license
Change-Id: I7eaf1d7bd11642f40a59505c1586fb393bf35283
2018-04-07 08:42:12 +00:00
Umherirrender 75ce384e42 Change ResultWrapper to IResultWrapper in special page
Follows core change I22ec4d3a9a19fc86efc9a2deb06f810695d38c85

Change-Id: I3f5e63478761e2cf312f75771b152d01111a3fa6
2018-04-07 10:35:58 +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 e99e181303 Add phan configuration
Depends-On: I09a0c0a786b687997e61344847f8af08b20cebf2
Change-Id: I9500232fb524e884d6cb15f2bdda10835df35ad4
2018-02-26 12:57:40 -08:00
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