Commit graph

121 commits

Author SHA1 Message Date
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 09397b5105 Merge "Pass whole context to internal action API requests" 2021-05-25 19:41:35 +00:00
jenkins-bot 6e6adb5508 Merge "Replace usage of deprecated User watchlist methods" 2021-04-30 18:41:16 +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
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
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
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
Ed Sanders 5e1b299c0b ApiVisualEditor: Return notices as an associative array
A couple of things make this quite a simple change:
* Most messages are generated from a single message key
* $title->getEditNotices() already returns an array
  keyed in the same way, we just currently flatten it.
* The VE client already flattens the array immediately
  in ArticleTarget#parseMetadata, so no change required.
* PHP preserves the order in which keys are added, not
  that notice order is particularly important.

This partially undoes c824dc383a,
which changed the format from a mixed array to an indexed array.

Bug: T272188
Change-Id: I646667fe2513e371e0c8270761553253d1abe2b6
2021-01-18 23:35:56 +00:00
Thiemo Kreuz f1dcc5d3c8 Prefer UserIdentity::isRegistered over isAnon
isRegistered is part of the slick UserIdentity interface, i.e.
it's the more "canonical" form. This change makes it a bit
easier to move away from using the huge (4000+ LOC) User class
everywhere, in favor of the UserIdentity interface, where
possible.

This patch is meant as a small step towards this goal. I tried
to replace some usages of User type hints already, but prefer
to go in small, incremental steps.

Change-Id: I827b83a5304b1975437d5fd5083f2877dba6f6d8
2021-01-07 17:01:22 +01:00
jenkins-bot 349a6e8568 Merge "ApiVisualEditor: Support 'preload' etc. for new sections in visual mode" 2021-01-05 14:23:26 +00:00
James D. Forrester 75f38008d9 Use User->isRegistered(), not deprecated isLoggedIn()
Bug: T270450
Change-Id: I5ed35fb2480a452219ac766e457333da955a10fe
2020-12-17 18:40:30 -08:00
Bartosz Dziewoński 4ca05702cd ApiVisualEditor: Support 'preload' etc. for new sections in visual mode
Bug: T269310
Change-Id: I66ed8449cae8e548c5b30f434cc8430fed128f14
2020-12-17 02:00:44 +01:00
Ostrzyciel 4614b3db11 Fix handling of EditFormPreloadText
The hook should work now.
I tested it manually and preloading with extensions works fine.
Preloading the default text for system messages is fixed as well.

Bug: T266404
Change-Id: Icf40112bd5fabf24452f9b807b388399c7c920f0
2020-10-30 20:28:43 +00:00
jenkins-bot a5cc81a630 Merge "Fix editnotice order in VisualEditor" 2020-10-19 20:15:21 +00:00
Ed Sanders 98a1c203c1 Filter empty edit notices
Bug: T265798
Change-Id: I10bc181b66288f89775566e1b06ae1e508484724
2020-10-17 16:31:27 +01:00
proc c824dc383a Fix editnotice order in VisualEditor
Bug: T263255
Change-Id: I83e6910c4886cc5a0170dc05e60459f3427aebe5
2020-10-16 01:14:21 +01:00
Thiemo Kreuz e13781ce1f Remove non-helpful lines of documentation
These do nothing but repeating literally what the code already
says.

Change-Id: I93c4a60f190e17a845e37e48b1c0a80bde2292c0
2020-10-07 15:24:50 +02:00
Thiemo Kreuz 1230e25cbf Add missing constant visibility keywords
Not used outside of this class. Confirmed via CodeSearch.

Change-Id: I8ffed9ed88bc60e7529d277df5b474d85437ed6e
2020-09-09 16:59:39 +02:00
Bartosz Dziewoński 8415d7f7bf ApiVisualEditor: Fix 'false' used as content for non-existent system messages
getDefaultMessageText() returns false when the message doesn't exist.
It was incorrectly treated as a string by this code.

Follow-up to 3ec5e04a37.

Change-Id: Ib94a30697bd20133e46cbd31c14caf5f0c4169dd
2020-08-16 21:06:18 +02:00
jenkins-bot 5c75faed31 Merge "Move parseWikitextFragment up to ApiParsoidTrait" 2020-07-27 17:01:13 +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 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
jenkins-bot e358865765 Merge "Replace uses of Revision constants" 2020-07-03 04:18:58 +00:00
Ed Sanders 3ec5e04a37 NWE: Pre-populate editor when editing system messages
This is the same behaviour as EditPage.php

Bug: T256999
Change-Id: Id33161982742c16222ba5d58d2e800ab04dccca2
2020-07-03 04:21:18 +02:00
DannyS712 5fb5bc3060 Replace uses of Revision constants
Bug: T257010
Change-Id: I20c7737d0d00b3f47c2781c1c968db6a74a68ad3
2020-07-03 00:40:59 +00:00
Bartosz Dziewoński c73953a5f7 Fix switching to visual with changes in non-RESTBase mode
Bug: T253467
Change-Id: I02a524a539530f1907f276ef80b666dd446ae6b3
2020-06-29 16:23:02 +00:00
Ed Sanders 703fbaa6a2 Factor out revision fetching and validation logic to ApiParsoidTrait
Change-Id: I7707b419afac2c11d7d0ca91a597ffc68e5e3fe4
2020-06-26 14:44:47 +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
jenkins-bot a28a263192 Merge "Drop linting from the VE API" 2020-06-04 17:12:54 +00:00
Ed Sanders f01d4ab35d Drop linting from the VE API
Calling the linter is very slow as the result is not
cached. Extensions needing this (DiscussionTools) should
just call the Linter extension API directly.

Bug: T253799
Change-Id: I994b52ca70c29a32900741a36087f10144396720
2020-06-04 18:51:38 +02:00
jenkins-bot c65b311ecb Merge "Tweaks in API code per code review" 2020-06-03 10:40:14 +00:00
Umherirrender 742d91fe37 Parse messages in string context
The current default for Message::__toString() is to parse, so this
keeps that behaviour unchanged.

Change-Id: I528a60c1d9c0f8c1596a15e06a764200a2b2565f
2020-05-24 14:46:40 +02:00
Bartosz Dziewoński 63638e380d Tweaks in API code per code review
Follow-up to If5c8d95560cbb078ae4980f4a912cbaeafe53d3e.

Change-Id: Iff72b5b21c0f5ce6a45cc48d6a8fc060159d7d23
2020-05-19 19:56:56 +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 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
Bartosz Dziewoński ae86f7290b ApiVisualEditor: Add option to return lint errors from Parsoid
Depends-On: I6bbe2fc5aea07c65eb99768f2c44ed42601792a3
Depends-On: I6bdf5635763ef8a44d44a031c64cd7f289261a32
Change-Id: I723ec766d1244d117f8d624440026fe5af0d3403
2020-04-21 22:49:29 +02: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
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
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