Commit graph

344 commits

Author SHA1 Message Date
jenkins-bot f9c2159c7d Merge "Simplify some API PHP code where possible" 2021-09-07 14:54:05 +00:00
libraryupgrader db01666a88 build: Updating mediawiki/mediawiki-phan-config to 0.11.0
Change-Id: I18aeec0e77c9aacfc4df8de485a246416cc0ecd3
2021-09-05 00:16:17 +00:00
Thiemo Kreuz a1464bd617 Simplify some API PHP code where possible
Change-Id: I663d9f2a25c70d8d265a3217cd1d0ad6fbb1bb3e
2021-08-26 11:37:13 +02:00
Alexander Vorwerk 821351d04f Make sure params is an array
This was removed in I44ee0014ac50c9c5dc66543dcd045dd5a81ce37c.

This basically partly reapplies I844db115f2563cb9ee1629c30d5f49d1ce58f5bd.

Bug: T289730
Change-Id: I14435b9f84b9a24445befbb8dc7fefce44bba078
2021-08-25 19:54:12 +00:00
Kosta Harlan f9ce087e67 ApiVisualEditorEdit: data-{plugin} is not multi
Specifying it as such creates a 0 based index for what is a single value
property. This wasn't noticed before because I6b81ea318f52e accessed the
request object directly instead of using $params. See also
I3baa1ebb66559 for how this bug manifested in GrowthExperiments.

Bug: T289652
Change-Id: Ife8350d1cea79fc1dd6f3cb040a7801b9fe6db91
2021-08-25 10:47:13 +02:00
jenkins-bot 46bccb570a Merge "Replace Content::preloadTransform call to ContentTransformer::preloadTransform" 2021-08-23 16:09:16 +00:00
Kosta Harlan b973ff3ee3 Introduce VisualEditorApiVisualEditorPreSaveHook
What:

Add a hook that runs before a save attempt is made in
ApiVisualEditorEdit. The hook receives the same data available in
ApiVisualEditorEdit, and implementations of the hook can modify the API
response.

Why:

VE plugins may send additional data when saving an edit, and extensions
might want to prevent the save from taking place based on that
additional data.

See for example the AddLink plugin in Ic8225933c9, where the save is
blocked if link suggestions don't exist in the database at save time.

Bug: T283109
Change-Id: I6b81ea318f52ec47661086d85b5cc242a3fcd0e4
2021-08-18 09:39:00 +02:00
Roman Stolar e6c93bfbda Replace Content::preloadTransform call to ContentTransformer::preloadTransform
Bug: T287157
Change-Id: I44ee0014ac50c9c5dc66543dcd045dd5a81ce37c
2021-08-17 16:53:49 +03:00
jenkins-bot 991e34c166 Merge "ApiVisualEditorEdit: inject services" 2021-08-11 20:08:42 +00:00
Roman Stolar 0519e98725 Replace Content::preSaveTransform call to ContentTransformer::preSaveTransform
Bug: T287156
Change-Id: Ieaf645dab42c0e6def9fc36ecc619843710656f4
2021-08-11 18:44:35 +03:00
Alexander Vorwerk 2fbd7f5c11 ApiVisualEditorEdit: inject services
This patch adds dependency injection for the ApiVisualEditorEdit api
module.

Change-Id: I4f75fc32ff422ca0e0f163add1346963eedcc635
2021-08-10 18:16:46 +00:00
Alexander Vorwerk 72693ca46b ApiVisualEditor: inject services
This patch add dependency injection for the ApiVisualEditor api
module.

Change-Id: I46a249fc1a8cf96102ee9fd64bf046d3a3d33361
2021-08-09 11:14:34 +00:00
libraryupgrader 30b68f3a74 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.1 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 1.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: Ia15aa76cb4abbfe42215532edf52b08c75f72034
2021-07-21 19:56:36 +00:00
Roman Stolar 304f3a30c6 Remove the fallback for create rights
It's covered in PM edit rights check throught getPermissionErrors method.

Bug: T272079
Change-Id: Idcf9ced5a638b173389c65d11b9d687f7fa3938e
2021-06-29 19:31:07 +03:00
Thiemo Kreuz c2017f74b2 Remove @param/@return docs that literally repeat the code
These don't add any knowledge but make the code harder to read
and maintain, and are an additional source of errors.

Change-Id: Ied57741a3f985e355adfddb4e75378d5c497faa9
2021-06-14 15:44:51 +02:00
jenkins-bot 353373cc1b Merge "Fix a series of minor style issues in PHP code" 2021-06-03 16:22:49 +00:00
Thiemo Kreuz ad014c834d Fix a series of minor style issues in PHP code
* Mismatching capitalization.
* Unused pieces of code.
* Properties that can be constants.
* Use $this->getConfig() in special pages.

Change-Id: Ia7e2c438c5ddd3c770070701e4cbdfc79fccf009
2021-06-03 15:55:38 +02:00
jenkins-bot edec0d10ec Merge "Use the edited page's title for magic words in API error messages" 2021-05-26 13:00:14 +00:00
jenkins-bot 09397b5105 Merge "Pass whole context to internal action API requests" 2021-05-25 19:41:35 +00:00
Bartosz Dziewoński 1f6466e93b Use the edited page's title for magic words in API error messages
Bug: T247661
Depends-On: Ic3d70efc23744ef6e90abc445f3babebf45c4697
Change-Id: I565c5391b0d3f0b5fae2366e06ad5e1a2a18301c
2021-05-21 18:04:01 +02:00
Andrew Kostka b2c9b225bd Add back button to the transclusion dialog
Bug: T272354
Change-Id: I08c4a7db6239b485439bf547e3e8b4d6f7aeede8
2021-05-17 13:18:14 +02:00
Adam Wight 85f45fd49d Introduce feature flag for template dialog sidebar changes
Bug: T274263
Change-Id: If274efa94474c3de79c5917b76c1a290f93172e1
2021-05-17 12:25:46 +02:00
Svantje Lilienthal 2665734b10 Renaming temporary config variable and splitting it from cirrus search lookup
This allows using the config variable independendly from the cirrus search extension.
This way it can be used for all subtickets of T271802.

Bug: T277028
Change-Id: I1b3bdda5fa6fbfe5c531c3b51c2c8e2a28ed1faf
2021-05-10 14:47:31 +02:00
jenkins-bot 5d1e79630f Merge "Introduce VisualEditorApiVisualEditorPostSaveHook" 2021-05-06 17:57:38 +00:00
jenkins-bot a4d1863a80 Merge "Use standard search API when searching for templates" 2021-05-03 08:12:35 +00:00
Kosta Harlan f035ce51f1 Introduce VisualEditorApiVisualEditorPostSaveHook
What:

Add hook that runs after a save attempt is made in ApiVisualEditorEdit.
The hook receives the same data available in ApiVisualEditorEdit, and
implementations of the hook can modify the API response.

Also introduce templated
parameters (https://www.mediawiki.org/wiki/API:Templated_parameters) in
the API parameters; this allows plugins to pass arbitrary data along
with their request using e.g. plugins=linkrecommendation&data-linkrecommendation=foo

Add ServiceWiring files, a PHP namespace, and a HookRunner class to
support the above changes.

Why:

VE plugins may wish to send additional data when saving an edit and take
action based on that data on the server-side. See for example the
AddLink plugin in I7a052f8e which sends annotation data, and then uses
the new hook to perform a database operation.

Change-Id: I392691475fbdcec766acbd832600e82efcb5bfe8
2021-04-30 20:50:01 +02:00
jenkins-bot 6e6adb5508 Merge "Replace usage of deprecated User watchlist methods" 2021-04-30 18:41:16 +00:00
Thiemo Kreuz 6e08a27fc7 Use standard search API when searching for templates
Bug: T274903
Change-Id: I7de8f6cc55ab678ed741ae5ebbaad608b9a9b0db
2021-04-30 12:52:45 +00:00
libraryupgrader 710e75dfb0 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: Iae29334b618b3f3758cb048394f85c0aca81b42c
2021-04-29 19:18:20 +00:00
Cindy Cicalese 442f5da371 Replace usage of deprecated User watchlist methods
This bumps the MediaWiki requirement to 1.37.

Bug: T281187
Change-Id: Iddcd1cbf67ad1f8e918c1da07347dd19e5f6f7d9
2021-04-29 09:32:22 -07:00
Bartosz Dziewoński 2f98128db7 Pass whole context to internal action API requests
Otherwise, the global context is used (RequestContext::getMain()),
which is undesirable when you're building a rubegoldbergian
contraption and we're already inside an internal action API request
with a fake context.

Change-Id: I66e79e641eda185f7af2561d3655c92cba762135
2021-04-29 02:30:59 +02:00
DannyS712 67a03105e0 ApiVisualEditor: remove call to deprecated User::isIP
Bug: T281401
Change-Id: I913e1ecaeadb2b36227b2dd205869db5f9a07691
2021-04-28 18:50:18 +00:00
Andrew Kostka 3c2db5fba9 Relocate parameter descriptions in the transclusion dialog
Bug: T273425
Change-Id: I2044b65ba88ae00e394fb84cb8e96a218995918a
2021-04-15 13:08:53 +02:00
Bartosz Dziewoński c832df5d3a api: Better error when a page with the given title can't exist
Bug: T279711
Change-Id: Icd7e7564bbbca47ea53dfe72c5f34ffa69ff3389
2021-04-14 16:11:18 +02:00
Bartosz Dziewoński aec35a67d0 api: Better error when 'wikitext' parameter is required
Bug: T280072
Change-Id: Ibd03aa2a527ac2d27ef7c3dbaf25df74a2a0fdc5
2021-04-14 16:10:26 +02:00
jenkins-bot 1e4de0e464 Merge "Add a combo box for suggested values in the transclusion dialog" 2021-04-09 10:40:33 +00:00
Bartosz Dziewoński 1b34b59aa7 SECURITY: Act like users don't exist if hidden from viewer (VE edit notices)
Applying the changes from the MediaWiki core patch for T120883
(Ife272a0eb1f3322bc8eb30ca803bd21801acba3e) to our duplicated
code implementing the same functionality.

Bug: T270453
Change-Id: I1b2de322aa0c69eb6d3b3ffadaed3fbaa3a58bca
2021-04-08 20:40:08 +01:00
Andrew Kostka de2f5b3055 Add a combo box for suggested values in the transclusion dialog
Bug: T271898
Change-Id: Ic637eea2cac45f79234b62c787e1b76d68b61570
2021-04-08 16:10:22 +02:00
Umherirrender ac5bd772a9 build: Remove unneeded @codingStandardsIgnore
line length was increased to 120 in 31.0.0

Bug: T278594
Change-Id: Ie5b28a7bfd5c9f795978d0773b02e080d9fe44a7
2021-04-03 21:41:58 +00:00
ZabeMath 3bd0f02ac2 Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I7395a8620064dcbe019b92feba17d9c9996ffbb7
2021-03-30 21:47:04 +00:00
Daimona Eaytoy 8f65b0c2e2 Stop using deprecated methods in Language
Change-Id: Id3b7cb3bc79e6d8189d45e638d928508308bb3e8
2021-02-27 13:51:49 +00:00
jenkins-bot 18f5e7e2f0 Merge "Fix $wgVisualEditorUseSingleEditTab compat with PostgreSQL" 2021-02-25 20:41:39 +00:00
vladshapik 3d29dd25e9 Avoid using User::IsIP
Remove using of User::isIP since this method will be hard-deprecated. Now it is soft-deprecated

Bug: T275602
Change-Id: Ia625be523706d1e24649f7aa15679491f9598b7f
2021-02-24 17:38:04 +02:00
Bartosz Dziewoński 932d009cd7 Fix $wgVisualEditorUseSingleEditTab compat with PostgreSQL
Bug: T270953
Change-Id: I30bd329e8c19d7b2e7ae905cead6b21b8584db5d
2021-02-24 00:31:44 +01:00
Bartosz Dziewoński e061cd5c3a VisualEditorDataModule: Use ResourceLoaderContext::encodeJson
Follow-up to Iab139c4dd69c9a16c9f4f9e2fd47ec76a9003152.

Change-Id: Ia16dad8b6c450f4cb095a67af1c1c2b487e8536b
2021-02-18 21:53:24 +01:00
Bartosz Dziewoński 2c5197f1b9 Fix Phan failure
The failure was:
includes/VisualEditorDataModule.php:37 PhanTypeMismatchArgument Argument 2 ($pretty) is ResourceLoader::inDebugMode() of type int but \FormatJson::encode() takes bool|false|string defined at ../../includes/json/FormatJson.php:115
includes/VisualEditorDataModule.php:41 PhanTypeMismatchArgument Argument 2 ($pretty) is ResourceLoader::inDebugMode() of type int but \FormatJson::encode() takes bool|false|string defined at ../../includes/json/FormatJson.php:115

Probably triggered by changes to MediaWiki in commit
Ieaf04e0c289646dd5d5b027b4f1f8278167b2d57.

Change-Id: Iab139c4dd69c9a16c9f4f9e2fd47ec76a9003152
2021-02-17 22:27:22 +01:00
Bartosz Dziewoński 263a4d1af7 Only show "Editing mode" preference when VE enabled (on SET beta-feature wikis)
Also, show the editing tabs dialog when appropriate.

Bug: T273189
Change-Id: I1293e0d69580372b23142493ee8905c18df40d23
2021-02-05 12:41:10 +00:00
Bartosz Dziewoński ef8e7945cc Stop showing the "Editing tabs" popup some time after SET switch
If someone has edited before the switch (2016-ish), never edited since
then, and try to edit again now, it's probably no longer helpful to
show them a popup dialog about a change that happened 5 years ago.

The immediate motivation for this, though, is T273189. We discovered a
bug with the preferences that, among other issues, caused this dialog
to not be shown in some cases where it should have been, and fixing
the bug now would cause it to be shown the on the next edit attempt.
If someone has edited before the switch (2016-ish), *and* edited since
then, and try to edit again now, it's definitely not helpful at all to
show them a popup dialog about a change that happened 5 years ago.

Bug: T273189
Change-Id: I4b5a3d8dbdf1c853eb39fcfc85a9fe87a4db0f21
2021-02-05 12:41:01 +00:00
Bartosz Dziewoński b91c8647fe Ignore user prefs for enabling/disabling VE which are not settable
We have two preferences used for enabling/disabling VE:
'visualeditor-enable' and 'visualeditor-betatempdisable'.
(And 'visualeditor-autodisable', which sometimes overrides
them both, but it's not relevant here.)

The user can only set 'visualeditor-enable' when VE is Beta Feature,
and they can only set 'visualeditor-betatempdisable' when it is not.

However, when deciding if VE should be loaded, we always checked both
of the preferences. This gives incorrect results when the preference
that is not supposed to be settable actually exists, due to being set
in GlobalPreferences on another wiki where it's settable.

A similar issue could occur if VE configuration is changed from Beta
Feature to a normal preference (or the other way around), and the
preference values for the previous configuration still persist.

Bug: T271434
Change-Id: I7399b3c516f762429050a662ac85d1d392392323
2021-02-05 12:40:51 +00:00
Bartosz Dziewoński 4b1f141511 Do not define contradictory user preferences for enabling/disabling VE
Depending on the config, we would sometimes define both the
'visualeditor-enable' and the 'visualeditor-betatempdisable'
preferences, even though they contradict each other.

Bug: T273188
Change-Id: I6ac7e4580bf232a5198ad8842f814bc381131e00
2021-02-05 12:40:38 +00:00