Commit graph

218 commits

Author SHA1 Message Date
Bartosz Dziewoński 73dcfb7122 ApiVisualEditorEdit: Fix handling of 'minor' parameter
The client-side code sends the empty string as the value of this
parameter when the edit should be marked as minor, and doesn't set it
at all when it shouldn't (this is the normal convention for boolean
parameters). However, the API code here was incorrectly handling the
empty string, and not marking the edit as minor as a result.

This was revealed by 50883dd7fe. Prior
to that change the original 'minor' parameter was forwarded to the
action=edit call if it was provided, overriding the 'notminor'
parameter, which was effectively added unconditionally.

Bug: T248257
Change-Id: I37fd73851d94906d79943692fb9136da03ea95fa
2020-03-23 17:36:34 +01:00
Bartosz Dziewoński 9e859a6145 ApiVisualEditorEdit: Remove unused output values 'basetimestamp', 'starttimestamp'
Our client-side code doesn't use them, and they should not be needed.

ApiVisualEditor still returns those, and they are needed there; this
method used to be shared by both classes until 25afae342a.

ApiVisualEditorEdit still has 'basetimestamp' and 'starttimestamp'
input parameters.

Change-Id: I7108468df2ff20f05bd141cb617e4e0f90c027ce
2020-03-17 21:04:51 +01:00
Bartosz Dziewoński 0039ca5bd3 ApiVisualEditorEdit: Remove unused variable $links
It was added in 78a52f1f80 (2014)
and apparently was never used?

Change-Id: I44a3305f805333f8ea3d35f4f937cc6210eb54eb
2020-03-17 20:38:53 +01:00
Bartosz Dziewoński 6d254de92e ApiVisualEditorEdit: Remove use of deprecated 'modulescripts'
It's unused and always empty, as of MediaWiki 1.33 (c6f34408).

Change-Id: I7997e8dcc5ce7221cf5586173dbb0fe62f9a7953
2020-03-17 20:31:45 +01:00
jenkins-bot 39a8ecf890 Merge "Remove X-Parsoid-Variant configuration value, which is no longer needed" 2020-03-17 00:13:39 +00:00
jenkins-bot c2975804a8 Merge "Don't pass through edit API params we've already handled" 2020-03-11 23:28:20 +00:00
C. Scott Ananian ce094c72d4 Remove X-Parsoid-Variant configuration value, which is no longer needed
Reverts Ib1403638b12ec5808f6b81bd114949043aa9ac2e.

Bug: T229074
Change-Id: I9bbc02821d5ee82c9944516ab07d3cb380d2f3a8
2020-03-11 13:24:43 -04:00
jenkins-bot 248f1ea5e4 Merge "Pass a user when creating a new ParserOptions" 2020-03-04 08:12:02 +00:00
DannyS712 0dca373c62 Pass a user when creating a new ParserOptions
Bug: T246861
Change-Id: Idaed22f2b4c1a43be97b48a7718cb5a35a58edd1
2020-03-04 04:57:45 +00:00
Petr Pchelko 543d436d79 Remove usage of deprecated Revision::newRevisionFromTitle
Bug: T246284
Change-Id: I3ba2de7bda3bdc228cb4136d0190c43188b9b185
2020-03-03 20:16:43 -08:00
Ed Sanders 50883dd7fe Don't pass through edit API params we've already handled
This can lead to problems if the names in the VE API are
still used inthe Edit API, as previously happened with
`watch`/`watchlist`.

Explicitly list the parameters from VE API that were
previously getting passed to the Edit API automatically.

Change-Id: I8fe705b178af82d8285067909168d32cfb9a0421
2020-02-29 17:51:52 +00:00
Ed Sanders 42194ec411 Fix checkbox handling in the API
The code for setting 'watchlist' in the EditAPI request
was completely broken as it always evaluated to 'unwatch'.
Instead pass through 'watchlist' directly from the client
where it must be set to 'watch' or 'unwatch'.

Bug: T245579
Change-Id: Ia5a2bb76ef35a685b39bcc0c4727796acd0f510d
2020-02-29 17:35:29 +00:00
James D. Forrester eb02880f20 Hooks::isSupportedEditPage: Re-format to make the logic clearer
Change-Id: I8959f1bc4c632fb80fc02374d6ecfc94ef06d9fc
2020-02-12 15:39:55 -08:00
DannyS712 cb1b9b5f20 Remove use of Title::quickUserCan
Bug: T244927
Change-Id: I6d7fb8825d512d1bf9c0005289b28704412975c3
2020-02-12 06:49:52 +00:00
David Lynch 95f034ffc4 VisualEditorHooks: don't duplicate tag definitions
Also update the doc comment for our tags hook, as we removed one hook.

Change-Id: I431a707e97de9eb24416ef7972b5c59fd66ac35a
2020-02-07 01:22:23 -06:00
David Lynch 0d6f984cc5 Change tags method so anon edits will go through
It turns out anonymous users can't apply change tags, so change
I2c1d0f8d69bc03e5c1877c790247e165f160e966 broke editing for them.

Bug: T242184
Change-Id: I7c27e4d9995428e213a980819810f235fdfe9435
2020-02-06 15:31:45 -06:00
jenkins-bot 22c6449d5f Merge "Don't offer switching to VE if it's disabled in preferences" 2020-02-05 01:48:34 +00:00
jenkins-bot 124ae7a444 Merge "Tag VE edits from the client-side" 2020-02-04 16:43:59 +00:00
jenkins-bot 6cd05e686d Merge "Don't display duplicate protection notices when user can't edit" 2020-02-03 17:33:39 +00:00
Bartosz Dziewoński ba3f222e42 Don't display duplicate protection notices when user can't edit
In the core MediaWiki editor, the detailed messages about page
protection are only shown when the user is allowed to edit the page;
otherwise, a generic permission error is shown. Do the same here.

Change-Id: Ia0ca52b9bf556354218b2aa91f141b429b0c5880
2020-01-31 14:55:32 -08:00
David Lynch d85d30f9b3 Tag VE edits from the client-side
This opens up the API so that other tools can use it without being
forced to tag those edits as being from VE.

Also, document that tags is a working parameter that can be passed
through to the edit API.

Bug: T242184
Change-Id: I2c1d0f8d69bc03e5c1877c790247e165f160e966
2020-01-29 21:55:07 -08:00
Thalia cbf259a6ed ApiVisualEditor: Replace calls to deprecated Title methods
Replace Title::userCan with PermissionManager::userCan.

Replace Title::getUserPermissionsErrors with
PermissionManager::getPermissionErrors.

Change-Id: I1afec4ba62185c3cd555a10ae35cef01b7194221
2020-01-29 20:58:19 -08:00
jenkins-bot 4c8c0e0253 Merge "ApiVisualEditor: Refactor edit notice code" 2020-01-29 21:46:00 +00:00
jenkins-bot 430d890cfb Merge "Pass the "count" parameter to 'cascadeprotectedwarning'" 2020-01-29 21:45:34 +00:00
jenkins-bot c72e3fbd48 Merge "Display log entry underneath 'titleprotectedwarning'" 2020-01-29 21:30:11 +00:00
Bartosz Dziewoński 3458d8a27e Don't offer switching to VE if it's disabled in preferences
In many places we check whether VE is available before doing things
(init.isVisualAvailable). This variable includes checks for whether
the page is wikitext, etc. Now it will also include checking whether
VE is enabled in user preferences.

In almost all places where init.isVisualAvailable is used, we were
already also checking if VE is enabled, so this doesn't affect the
behavior. But notably, we didn't do it when showing the option to
switch to VE in the welcome dialog and in the toolbar, causing T243723.

Changing init.isVisualAvailable this way makes it consistent with
init.isWikitextAvailable, which has always included a checking whether
NWE is enabled in user preferences.

Bug: T243723
Change-Id: Ie174bc3f16bceb29cb155b9223e0acef70167fd6
2020-01-28 16:26:03 -08:00
libraryupgrader 1baeb9ef0c build: Updating composer dependencies
* mediawiki/minus-x: 0.3.2 → 1.0.0
* mediawiki/mediawiki-phan-config: 0.9.0 → 0.9.1

Change-Id: Ibf55f382c586603967da0086f86bfe4924e7cf96
2020-01-26 18:27:39 +00:00
Bartosz Dziewoński a9066989f2 ApiVisualEditor: Refactor edit notice code
* Query permission errors for 'edit' and 'create' in the same way,
  and consistently with how MediaWiki core EditPage does it.

* Prefer using Title::getUserPermissionsErrors() instead of custom
  code for user blocks. The result is the same, except for an extra
  line like "You do not have permission to edit this page, for the
  following reason:".

  Note that this loses the 'type' => 'block' property on each notice,
  which was previously used to track when a block notice was shown.
  This was however removed in 96de1353d3,
  and could probably be re-implemented by using the root 'blockinfo'
  property anyway.

* When Title::getUserPermissionsErrors() returns multiple messages
  (for example, you're blocked *and* the page is protected),
  display them all in a list instead of only the first one, using
  OutputPage::formatPermissionsErrorMessage().

  That method returns wikitext, which we have to parse ourselves. This
  is a bit silly, but I found this approach in SpecialChangeContentModel
  in MediaWiki core, so it should be fine.

Change-Id: Ifaf95d8aab836e45665b1fbdf98dd1980a867d8c
2020-01-17 01:18:46 +01:00
Bartosz Dziewoński ac36b242c3 Pass the "count" parameter to 'cascadeprotectedwarning'
It will now correctly say "page" instead of "pages" when there is just one.

Change-Id: I7be6368da977a7eeba976ca63134efce3db1e01a
2020-01-17 01:17:30 +01:00
Bartosz Dziewoński 18c899374b Display log entry underneath 'titleprotectedwarning'
The message ends with "The latest log entry is provided below for
reference:", but we were not providing it. Use the same code as
'protectedpagewarning' and 'semiprotectedpagewarning', which behave
the same.

Change-Id: Ibe5463aa3d93cd1d6d6e3c0b9da82bfa2c813f86
2020-01-17 01:08:12 +01:00
jenkins-bot 523e9379c2 Merge "ApiVisualEditor.php: Add notices also when not blocked" 2020-01-16 23:29:36 +00:00
Umherirrender a7497703a7 Fix new documentation sniffs
Change-Id: If9fc2d1d29aefdcb61a5f69c28f7d50c86b3ac4a
2020-01-10 16:28:16 -08:00
libraryupgrader 6afa14fe4d build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag

Change-Id: If59d450236a7d1afa3c6a05536abea819535f984
2020-01-10 17:51:43 +00:00
James D. Forrester 2c77e88d2c doc: Bump copyright year for 2020
Change-Id: I30539877543dc2a57bd1428a00d10ac46d8fc294
2020-01-08 09:13:24 -08:00
jenkins-bot 3e3a84f9b6 Merge "Fix 2017WTE change tag for edits that blank the page" 2020-01-06 18:30:29 +00:00
lens0021 a01f28c8a3
ApiVisualEditor.php: Add notices also when not blocked
Bug: T241693
Change-Id: I2c4355f7a2398b742d635f1de0cf87d4ec527cb3
2020-01-06 17:41:17 +09:00
Bartosz Dziewoński 54f2ba68d7 Fix 2017WTE change tag for edits that blank the page
Bug: T241797
Change-Id: I5c843f7ebcffba720f3dd0564947c197a76cf82e
2020-01-03 08:49:44 +01:00
Ed Sanders 21b676452e Fix Special: title in ApiVisualEditorEdit
We also do this in ApiVisualEditor.

Change-Id: I5c27c6e7770d0a5093684cadeaf1786f85dc32ff
2019-12-20 15:50:48 +00:00
jenkins-bot 0d0ef6071f Merge "Remove an unused piece of code from ApiVisualEditor" 2019-12-18 10:30:22 +00:00
Thiemo Kreuz 8e4dc67ec7 Fix unchecked array access in ApiVisualEditor
I'm not sure if this qualifies as an actual fix. I don't really know
what this code is supposed to do. Maybe the bad array access is a hint
for a completely different error somewhere else. All this patch really
does is silencing the bad array access.

This line of code was introduced with I1b35b28 in May already. Why does
it start failing now?

Bug: T240961
Change-Id: I5ec2dc453e5d8db5d2f9e49058eda001ed021d3d
2019-12-18 08:22:25 +01:00
Thiemo Kreuz 0f4918e3e3 Remove an unused piece of code from ApiVisualEditor
Change-Id: I5ca2ad9df0decfada199d44366de8efc9f2b26ac
2019-12-18 08:17:01 +01:00
libraryupgrader c8de97fcd2 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Change-Id: Iaaea284190aa9306177b3ee945a75da631a89b93
2019-12-16 10:11:47 +00:00
jenkins-bot af700cd536 Merge "ApiVisualEditorEdit: Normalize newlines in wikitext" 2019-12-13 15:42:50 +00:00
Bartosz Dziewoński 9779336403 ApiVisualEditorEdit: Simplify diff handling a bit more!
Dealing with `result: 'nochanges'` is annoying. Just return an empty
diff to indicate no changes.

Change-Id: I192caa67ec85224500a6919efd370cf7b5c1c592
2019-11-24 09:51:54 +00:00
Bartosz Dziewoński 1e890f975f ApiVisualEditorEdit: Simplify diff handling a bit
I'm trying to track down possible values of 'result' for client-side
error handling and this was confusing.

Change-Id: I325249f7c57936c9c11a1d3dc9166b1ca3737c39
2019-11-18 15:57:36 -05:00
Bartosz Dziewoński a4d7c41e68 ApiVisualEditorEdit: Normalize newlines in wikitext
Firefox apparently sends us \r\n newlines, even though we use \n.

Bug: T154977
Change-Id: I22e9a2e11c63ab62b6e37c86455638bf23d5b431
2019-11-13 23:24:06 +01:00
David Lynch 46e7b3ba19 Config value for X-Parsoid-Variant
Bug: T229074
Change-Id: Ib1403638b12ec5808f6b81bd114949043aa9ac2e
2019-11-05 10:56:10 -06:00
Ed Sanders 76d0f02116 Use MobileFrontend check for loading DesktopArticleTarget.init
Bug: T236944
Change-Id: I3fd41d0fbb3087d4052db1cb1537e289defa737e
2019-11-01 22:05:59 +00:00
Ed Sanders 1bb72f0bb5 Replace deprecated easy-deflate.deflate with mediawiki.deflate
Change-Id: I5c77d4818074fd3dc937d7688d449952b92ee358
2019-10-30 19:13:47 +00:00
James D. Forrester 2479f5c7f8 Drop use of wgParser, replaced in 1.32 and to be removed in 1.35
Bug: T160811
Change-Id: Id7332a19d64d83bcbccfd3ac89464dfea593cdc2
2019-10-28 20:10:14 +00:00