Commit graph

61 commits

Author SHA1 Message Date
jenkins-bot 5c75faed31 Merge "Move parseWikitextFragment up to ApiParsoidTrait" 2020-07-27 17:01:13 +00:00
jenkins-bot 9d6713bb2d Merge "Refactor postHTML in ApiParsoidTrait" 2020-07-27 16:59:31 +00:00
Ed Sanders eb98439453 Move parseWikitextFragment up to ApiParsoidTrait
Rename to 'transformWikitext' and rename 'postHTML' to match.

Change-Id: Icb1f519c7a3a88f36c51479333be8cfb5617dbe0
2020-07-22 14:44:11 +01:00
Ed Sanders 90bf7e0488 Refactor postHTML in ApiParsoidTrait
* Remove postHTML/postData separation, not very useful.
* Pass $oldid instead of full params object.
* Return full repsonse like other methods, instead of just body.

Change-Id: I0fe301475adeb0fd5952809c3f74f0cb19f89cfe
2020-07-22 14:44:11 +01:00
Ed Sanders 9089993417 API: Use ParamValidator constants
Also drop mustBePosted functions as the default implement
is already correct.

Change-Id: Ib8e0fe3f2638892df768438c9f47f90b4ca66968
2020-07-20 21:43:59 +01:00
Ed Sanders afc22db25d ApiParsoidTrait: Add typehints
Suggests redundant checks that can be removed.

Change-Id: I238632e0a9af568f7c7a9897c43e4143dc9ebce8
2020-06-26 14:45:16 +02:00
Bartosz Dziewoński 1b86093b70 api: Specify PARAM_TYPE => 'text' for multi-line text parameters
This allows Special:ApiSandbox to display multi-line text boxes for
them, which makes testing the API easier.

Change-Id: I10541a8e9033d81740033da80d842f58d1d3e0de
2020-06-10 21:23:13 +02:00
Bartosz Dziewoński 0528f806fa Extract Parsoid/RESTBase stuff out of our API code
Goals:
* Allow other extensions to reuse these methods (maybe upstream them
  to MediaWiki core later)
* Allow ApiVisualEditorEdit to extend ApiEditPage. We'll be able to
  reuse its definitions for API parameters instead of duplicating
  them, and we won't have to pass around unrecognized parameters.

Bug: T252573
Change-Id: If5c8d95560cbb078ae4980f4a912cbaeafe53d3e
2020-05-12 21:17:29 +02:00
Bartosz Dziewoński 91d40cdfc4 ApiVisualEditorEdit: Use existing action=compare parameters for PST
Change-Id: I436218871e0fae07b39b0c3aa75a0d00bc5fc6b2
2020-05-12 20:56:23 +02:00
Bartosz Dziewoński d92e600d58 Simplify API modules setup
We go through all this trouble to pass the config to the API modules,
and then we don't use it at all (we removed the uses recently in
ce094c72d and d85d30f9b).

If we end up needing the config there again, we can just get it by using
MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'visualeditor' )
anywhere we want, like we do all over the place in VisualEditorHooks.

Change-Id: I9d254a9946f0d24783baf68c409b10291a8fd1b3
2020-05-12 18:53:31 +02:00
James D. Forrester a4dee12d83 Replace class_exists with ExtensionRegistry::isLoaded()
Change-Id: I229f83cd18473bb3c89c376b0e2ec62d13feff37
2020-04-20 15:07:01 -07:00
DannyS712 de392e6133 Remove use of Revision::newFromId
Bug: T246284
Change-Id: Ia3de1caeac5edb2a8ee272fb9b80d36e1d778314
2020-03-30 04:45:24 +00:00
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
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
jenkins-bot 124ae7a444 Merge "Tag VE edits from the client-side" 2020-02-04 16:43:59 +00: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
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
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
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
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
Ed Sanders 1bb72f0bb5 Replace deprecated easy-deflate.deflate with mediawiki.deflate
Change-Id: I5c77d4818074fd3dc937d7688d449952b92ee358
2019-10-30 19:13:47 +00:00
Bartosz Dziewoński cbd500a9ee Don't log missing ETags when creating a new page, that's normal
Same idea as f3dfd98e55. Oops.

Bug: T233320
Change-Id: Id31bd4806da5489a4438d385553a22d33676fc3a
2019-10-23 22:15:03 +02:00
Bartosz Dziewoński f7ee7dc807 Try using structured logging again
The configuration of Wikimedia wikis should be fixed.

This reverts commit 04407e9eb1
and also makes similar changes to new logging code added in
5d1a67757a.

Bug: T234564
Change-Id: Ic999b050e68b71f5a1737366e16f133e5a557307
2019-10-21 17:04:23 +02:00
James D. Forrester dec54cf56e build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I23702d16eee09292b63051f94103a3bca3b1dd13
2019-10-11 12:42:23 -07:00
Bartosz Dziewoński 04407e9eb1 Don't try to use structured data in structured logging, it doesn't work
Our log messages were being silently dropped. Experimentation revealed
that our structured logging system doesn't actually like it when we
try to log structured data.

See: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/540464/3/includes/ApiVisualEditorEdit.php

Put it all in the message strings, whatever.

Change-Id: Iae778f95774df2e24b30387221e39e097e25a4cf
2019-10-02 23:13:40 +02:00
Bartosz Dziewoński df0c8ad02d ApiVisualEditorEdit: Add logging for funny etags
Bug: T233320
Change-Id: I0f321df057068e1dd396a04a9e194853c2b0e9e4
2019-10-02 03:23:29 +02:00
Bartosz Dziewoński 7c2e61d502 ApiVisualEditorEdit: Remove special handling for SpamBlacklist
No longer needed after Id36aa6bdb8f873fe7deb8123a7fc774103721c01,
which teaches SpamBlacklist to return its own error messages.

Depends-On: Id36aa6bdb8f873fe7deb8123a7fc774103721c01
Bug: T211443
Change-Id: I462c2002f9b596cbdfd7ce3673d4e362e5bd1aaf
2019-09-11 21:55:25 +00:00
DannyS712 00a98dd8f2 Fix 'paramter' typo in code and add to typos list, now covering PHP
Bug: T201491
Change-Id: I28d3b3871a2de54e575163bec7c364b68da8d5a6
2019-08-20 12:10:04 +01:00
Ed Sanders 3a4822c2fe Section switch from wikitext to VE
Use an API 'parse' call with a sectionid to trigger
a full document expansion using replaceSectionAtRev.

Then send this off the RESTBase to convert to HTML
and statsh.

Ensure the etag is passed back to the API response.

Bug: T117716
Bug: T223023
Change-Id: I1b35b28e428a1f86d2e34d90ddbe73361ce14818
2019-05-13 19:49:10 +01:00
Aaron Schulz e2fa08f0f8 Use PageEditStash services instead of static methods
Change-Id: I1bcda750a22dcacfffa0f7400411a7653806a82e
2019-04-23 12:45:21 -07:00
Aaron Schulz 1a5fc05dda Avoid keeping excess keys from storeInSerializationCache() in cache
Remove overkill $VisualEditorSerializationCacheTimeout config setting
and just use a simple constant instead (convention over configuration).

Bug: T203786
Change-Id: I94424088a03a3262fcea30132883a612465c546e
2019-04-03 18:34:07 +00:00
Aaron Schulz a56fbba6c3 Clean up serialization cache code a bit and add more metrics
Change-Id: Ib2024026a2b6f42ed0c56479a0cec2a8cbd1e3bc
2019-03-28 00:26:37 +00:00
Umherirrender de8b4b5d29 Use php null coalesce operator ??
Change-Id: I756fa99084cbb86357ac840b3338d296863eecc4
2019-03-12 21:27:47 +01:00
jenkins-bot f501a5238b Merge "Fix return type of ApiVisualEditorEdit::saveWikitext" 2019-03-08 20:50:04 +00:00
jenkins-bot 476ffbba68 Merge "Use DerivativeContext in ApiVisualEditorEdit" 2019-03-04 19:09:19 +00:00
Umherirrender c9a3bf9fa5 Use DerivativeContext in ApiVisualEditorEdit
Using DerivativeContext also makes the code easier to read.
getContext() returns an IContextSource, in this interface has no
setRequest() method and this can fail for some kinds of IContextSource.
$view is a ContextSource, which implements setContext().
This also allows us pass in a new context with the right request object,
and also to set the title so we don't have different titles
on $view and the main context.

Change-Id: Ia575cd6163defeb423a542e342034cac5eb6108c
2019-03-04 18:36:47 +00:00
Umherirrender a07ad01594 Use ::class for class name resolution
Available since php5.5

Change-Id: I9392155193275d20a82bde8eb7964d466e190f6b
2019-03-02 23:46:12 +01:00
Umherirrender 8c1eda388e Fix return type of ApiVisualEditorEdit::saveWikitext
Change-Id: I523d8097b39d80fc7082c64009b49b36f8a296a7
2019-03-02 18:04:14 +00:00
Umherirrender 57d00b7197 Improve param docs
Change-Id: Ib8e22c6029cb11635d6fe9cce17775f67a2a589a
2019-01-26 14:50:22 +01:00
James D. Forrester 3c293ea00c doc: Bump copyright year for 2019
Change-Id: I8991b97c980d4149f53eb5601036220ef3c0c440
2019-01-01 13:24:23 +00:00