Commit graph

138 commits

Author SHA1 Message Date
Bartosz Dziewoński a420141b2a ApiVisualEditor: Fix 'stash' param validation (it's a boolean)
Bug: T306190
Change-Id: I49a479f79d220c7436364f7543bae9e091fff6a2
2022-04-19 21:53:03 +02:00
Umherirrender 47d1d4b385 Remove usage of protection related deprecated Title function
Bug: T306131
Change-Id: Id551a318a9bb1047e449e0ad284b8f73c8886aad
2022-04-14 22:06:02 +02:00
Reedy 239fbb64e4 Namespace rest of the extension
Change-Id: I4f3e2793099d81401035ea282f268a3afaa03067
2022-03-14 22:27:15 +00:00
jenkins-bot 35e1f36b7b Merge "ApiVisualEditor: Remove $wgTitle hack, set page for {{PAGENAME}} when needed" 2022-03-10 13:07:10 +00:00
Bartosz Dziewoński aed5bcf7d0 ApiVisualEditor: Remove $wgTitle hack, set page for {{PAGENAME}} when needed
Depends on core changes I242e042317 and I6e9356a6cc to set the context
page for messages generated in Title::getEditNotices() and
LogEventsList::showLogExtract() too.

Set the context page for other messages whose overrides on Wikimedia
wikis commonly depend on it, which I checked using Global Search, e.g.
https://global-search.toolforge.org/?q=PAGENAME&regex=1&namespaces=8&title=Editingold

Depends-On: I242e042317a1e16c8d51edbf7800c8b7d70d468e
Depends-On: I6e9356a6cc3b9df9b508c3d37a0b9b75d6825efd
Bug: T300184
Change-Id: I0746618b1f6da3e5fd213d8adad9b1f4ec2fe23b
2022-02-28 23:43:54 +00:00
Thalia b0c0917f19 ApiVisualEditor: Support Special:MyLanguage for preload param
This allows nonexistent translated pages to fall back to the
corresponding page in a suitable language.

Bug: T299544
Change-Id: I43f461e9f595c364ecdaf2faccbd580fc0df6799
2022-02-25 12:23:16 +00:00
Bartosz Dziewoński 8c0a6bce38 Modernize some warnings about account not being registered
Matching MediaWiki change I7a7046bf9b9765cbb82ec3caa1530de7f05e0da4.

Change-Id: I5b2587f00d00622a5e431d0fd69bdf8979b7bc53
2022-02-09 21:26:18 +01:00
Bartosz Dziewoński 72c68e9e65 Remove redundant Phan annotations
Change-Id: Ic87fcc132b310191b086ccf7facfdf262a544eb9
2022-02-05 16:55:42 +01:00
Bartosz Dziewoński 8080bd2f5d Move copyright warning message parsing from RL module to API
Parsing it in the RL module caused the module cache key to depend
on the parse, which is slow and makes ResourceLoader sad. The usual
approach for solving this (I206bb05d28) can't be used, because of
how EditPage generates this message.

Bonus #1:
Generate the message for the correct page title. MediaWiki allows
customizing it per-namespace or even per-title, which we haven't
supported before.

Bonus #2:
Pass the context for message localisation (depends on I5f7c77970d).
EditPage::getCopyrightWarning() was parsing messages without the
interface flag, causing some needless processing elsewhere.

Depends-On: I5f7c77970d0525c0ff394f8bd72c69dcb5d00623
Bug: T298822
Change-Id: Iaa626f0e6379a5a370f9c465cea8528bb5bde7f7
2022-01-24 22:19:04 +00:00
Alexander Vorwerk 61e0094574 Replace usage of deprecated global function wfReadOnly()
The global function wfReadOnly() has been deprecated in favor of the
new ReadOnlyMode service. Its usages should be replaced.

Bug: T283978
Change-Id: I26a878f19be5c90dab04e28ce395cb8f6dddebef
2021-12-26 14:23:42 +01:00
vladshapik f17e84b331 Avoid using User::isBlockedFrom()
Replace User::isBlockedFrom with PermissionManager::isBlockedFrom since this method will be hard-deprecated.

Bug: T294823
Change-Id: Iea308ce73e4e91b21f55b60e0b3251d93ba18d7e
2021-11-02 13:13:12 +02:00
Thiemo Kreuz a3a738b4f9 Rewrite ApiVisualEditor::getAvailableNamespaceIds()
For readability. The current implementation is a sequence of
7 (!) array_…() function calls. It is also not free from bugs.
If one of the two inputs (ExtensionRegistry and Config) specifies
namespaces by e.g. canonical name, but the other by number,
the two are not properly merged. It should be possible to use
configuration to disable a namespace that would otherwise be
enabled. This currently works only if both use the same array
keys.

Bug: T291727
Change-Id: I2671f391cdc510da21eda8a1dc5ed4d2513a378a
2021-10-01 14:10:08 +02:00
DannyS712 492fcfbd9f Don't include null in the namespaces where VE can be enabled
Bug: T291728
Change-Id: I2cb168a21c559e61bf2c9e881d46f7f23110e826
2021-09-29 16:23:48 +00: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
Roman Stolar e6c93bfbda Replace Content::preloadTransform call to ContentTransformer::preloadTransform
Bug: T287157
Change-Id: I44ee0014ac50c9c5dc66543dcd045dd5a81ce37c
2021-08-17 16:53:49 +03: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 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
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