Commit graph

116 commits

Author SHA1 Message Date
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 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
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
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
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