Commit graph

480 commits

Author SHA1 Message Date
Bartosz Dziewoński 6f3de6d7f0 Improve some API param docs and validation
Change-Id: Ic1319f82e581b1a3c2108ab32449ce75aa187831
2022-09-02 04:20:41 +02:00
jenkins-bot ce37169a51 Merge "Don't send missing $wgVisualEditorTabMessages to the browser" 2022-08-26 18:57:07 +00:00
Bartosz Dziewoński 951348dbbf ParsoidHelper: Stop logging missing etags
While a missing etag on a RESTBase wiki still indicates a problem,
we worked around these problems long ago in T233320 and we don't
really care about the logs any more, and the logging is now dominated
by requests on private wikis where etags are not expected.

Bug: T316234
Change-Id: I4cc29847524863af2c5642cb60371893533a9df8
2022-08-25 21:23:35 +02:00
Bartosz Dziewoński f2df5dc7b9 Improve error messages for RESTBase errors
For error responses, the response body should be JSON containing a
'detail' key with a human-readable error message.

Remove old debug logging for T233320, it's no longer needed and it
stopped working on WMF wikis anyway (again, previously it was broken
due to T234564).

Change-Id: I64d0b934c90c7e9582e5433ae7a1b9ed2bc0c9a2
2022-08-19 21:13:35 +00:00
Timo Tijhof 3901a8a4f1 ApiVisualEditorEdit: Switch to non-global FlaggablePageView::newFromTitle
Introduced in FlaggedRevs with Idbdab9a7396 (6bfd276e64), and I've
migrated consumers away from the singleton in I192b962147 (5ee96e5ca7)
and I04fdbd497b8 (bbdfc4c024).

The one thing that remains global by default is the context, but
VE already avoids that with setContext, and (correctly) restores this
afterward since the FlaggablePageView object is re-used by title.
That's exactly as terrible as it sounds, but at least it's a bit more
visible after my refactor.

Bug: T314008
Change-Id: I0008818ec821c35c570d9db9c82f737783e6729b
2022-08-15 18:02:24 +00:00
Bartosz Dziewoński 84433157aa Migrate usage of Database::select to SelectQueryBuilder
We can simplify the code in Hooks.php to use revision.rev_actor
unconditionally, reverting 391c30da67
(the migration is done: T275246).

Bug: T312472
Change-Id: Iaab268409ec4ad0a8d3a835057321aa3c01a2cc7
2022-08-12 22:35:30 +00:00
jenkins-bot efdde38f85 Merge "Create Parsoid helper for use outside of action API" 2022-08-11 13:39:29 +00:00
Bartosz Dziewoński 8d735bbd9e Create Parsoid helper for use outside of action API
ApiParsoidTrait depends on some ApiBase methods, which is inconvenient
when one wishes to access Parsoid HTML outside of the action API. Move
the bulk of the code into a new class ParsoidHelper, which doesn't.

Replace the uses of methods:
* dieWithError: throw a different kind of exception where it makes
  sense, or change the method to return a StatusValue instead of
  throwing where it doesn't
* getPageLanguage: use Title::getPageLanguage() or pass as parameter
* getConfig: pass to constructor
* getLogger: pass to constructor
* getRequest: pass the only required part to constructor,
  leave some other API-specific code using it in ApiParsoidTrait

Bug: T314565
Change-Id: I90656cc74bb1cb1f2f3c82ad51cfb164cb8a4a4b
2022-08-10 23:20:59 +00:00
jenkins-bot 484dcffaab Merge "ApiParsoidTrait: Mark private methods and properties" 2022-08-10 17:12:03 +00:00
jenkins-bot ebef91b210 Merge "Update code for setting user preferences" 2022-08-10 16:44:42 +00:00
Bartosz Dziewoński 6980c966cd ApiParsoidTrait: Mark private methods and properties
They are not accessed outside this trait.

Change-Id: Ib238c0d5507f717ab0d4af2b6e452c255d260fd0
2022-08-09 23:42:35 +02:00
jenkins-bot dbecc84755 Merge "ApiVisualEditorEdit: Re-order FlaggedRevs logic to avoid breakage" 2022-08-08 09:17:47 +00:00
Subramanya Sastry 5319c49df0 Update call to PageConfigFactory::create to use new signature
* Followup to 43231df9

Bug: T314523
Change-Id: I9a299321344c7bbd481f96132393c45b31a93e52
2022-08-03 15:06:52 -05:00
Timo Tijhof f43dfea1b5 ApiVisualEditorEdit: Re-order FlaggedRevs logic to avoid breakage
Needed for Idbdab9a73964efa5 and I09eb8c3a38c0d4.

Bug: T314008
Change-Id: I8575bb40d0a9d24d481b6f58cd9ba500fe0f0f13
2022-08-01 16:23:10 -07:00
C. Scott Ananian d668492e58 ApiVisualEditorEdit: Transition from 'hidetoc' to 'showtoc' in API result
Bug: T314000
Depends-On: I1644a74370b42b04d0db167879f7de2207ebfcf5
Change-Id: I823f26652b9770ea577daee32bff05864a7498bb
2022-07-28 14:55:27 +00:00
Thiemo Kreuz f09f704364 Don't send missing $wgVisualEditorTabMessages to the browser
This is send as an associative array. Instead of adding elements that
are null we can just not add them.

Bug: T291729
Change-Id: I28d847941eec865cb255779534eca14ec88f588f
2022-07-27 09:13:48 +02:00
C. Scott Ananian 43231df98a VisualEditorParsoidClient: use the new PageConfigFactory::create() signature
Depends-On: I79a2773bf6d2366593b31555afd0b548b66d222a
Change-Id: I40b0c7159c493f7ff12085f9845fc5399102df2f
2022-07-26 21:21:40 +00:00
vahurzpu 766884b41d ApiVisualEditor: set title when expanding permission editnotices
Before, permission editnotices didn't have access to the page titles, so
magic words like {{PAGENAME}} would give a subpage of Special:Badtitle. This
formats the message in the appropriate context.

Bug: T313372
Change-Id: I93894a4fc129de9da4b120c084b1d343b4021cdd
2022-07-20 10:48:56 -04:00
Thiemo Kreuz 139e6547d1 Remove unused media/meta-related messages
visualeditor-dialog-media-thumbdimensions
Added in 2014 via I7b4d019, but never used, as far as I can tell.

visualeditor-dialog-media-searchselect
Unused since I65aed34 from 2015.

visualeditor-dialog-meta-settings-displaytitle-enable
The feature was removed in 2017 via I46db6b1.

This patch also marks some other messages as being used via comments.

Change-Id: Ia10b6a5c0ea83dd670e2cfdbaa768c41fc0cf392
2022-07-13 13:56:41 +02:00
jenkins-bot 93b18174c1 Merge "Avoid preloading base translation page in editor" 2022-06-26 19:17:17 +00:00
Umherirrender ab823c0115 Replace deprecated WikiPage::factory
Remove WikiFilePage instance check, isLocal exists also on WikiPage and
newFromTitle never returns null

Bug: T297688
Change-Id: I925771a84afe4402fdb0f201c0b562c7028c44b2
2022-06-24 23:06:39 +02:00
Thalia 73d163e77a Avoid preloading base translation page in editor
Bug: T309329
Depends-On: I739cee94620bc8d0689a4d3ec5898bfd75c18b8a
Change-Id: I29aa56627c74edf38573fd9aff52a015de92cc00
2022-06-22 14:59:57 +01:00
Jon Robson 3d4e0f71b1 Use SkinTemplateNavigation::Universal
Web team plans to deprecate the SkinTemplateNavigation
and  SkinTemplateNavigation::SpecialPage hook. The
Universal hook can cater for both cases.

Bug: T255319
Change-Id: Ifad4918cf5d3d6b3f4d7abeb48d27fc5a46764b3
2022-06-21 22:34:55 +00:00
Bartosz Dziewoński a2611086d0 Update code for setting user preferences
Bug: T310809
Change-Id: I0a2d58517a94f5fd52cd83cc42d440d69c2e97a7
2022-06-21 19:44:50 +02:00
jenkins-bot 5e0755d369 Merge "Force "new template dialog sidebar" feature flag to be true" 2022-06-17 07:12:27 +00:00
jenkins-bot 1119d52cd8 Merge "Fire new 'wikipage.tableOfContents' hook to update TOC after save" 2022-06-16 17:28:50 +00:00
Thiemo Kreuz cf9fea9688 Force "new template dialog sidebar" feature flag to be true
I suggest this as the first, most minimal step. This allows us to
slowly remove all the code that uses this flag without breaking
anything on wikis where the feature flag is not enabled. In other
words: this patch turns all code that expects this flag to be false
into dead code. We can then slowly remove said dead code.

Bug: T289049
Change-Id: I523978f7ca72dfc1cc7b64741e2f4f20ed3adfb7
2022-06-16 18:09:26 +02:00
Adam Wight 1b4c81c27d Remove $wgVisualEditorTransclusionDialogInlineDescriptions feature flag
The feature is always enabled now.

Bug: T307188
Change-Id: Id8b39d44901dee9118837fc4670d7faa4ef19b43
2022-06-15 12:09:47 +02:00
Adam Wight e1ea921f76 Remove $wgVisualEditorTemplateSearchImprovements feature flag
The feature is always enabled now.

Bug: T307188
Change-Id: I34a3db44355d93413f611b99cd80b876d8737413
2022-06-14 10:48:19 +02:00
jenkins-bot d7140912c7 Merge "Fix tab messages being changed wrong by JavaScript" 2022-06-13 21:15:09 +00:00
Bartosz Dziewoński dc842277c7 Fix tab messages being changed wrong by JavaScript
Following the MediaWiki changes from T301203, we should use
the messages 'skin-view-edit' and 'skin-view-create' instead
of 'edit' and 'create'.

(Also remove redundant definitions in extension.json, we load
all messages listed in 'VisualEditorTabMessages'.)

Bug: T310529
Change-Id: If055fa2a4dc009be869425e6c2262c9b62056179
2022-06-13 20:21:32 +02:00
jenkins-bot fcf849ddb0 Merge "Remove $wgVisualEditorTransclusionDialogBackButton feature flag" 2022-06-13 08:12:40 +00:00
Adam Wight 2e2e40e76e Remove $wgVisualEditorTransclusionDialogBackButton feature flag
Feature is always enabled now.

Bug: T307188
Change-Id: I70305ec3d2ed9cfb767ee9ea90e8ed6c93cfbdbb
2022-06-10 17:33:56 +02:00
Adam Wight 23f0bdf822 Remove $wgVisualEditorTransclusionDialogSuggestedValues feature flag
Feature is always enabled now.

Bug: T307188
Change-Id: I6f8288d31fecc6827a7a9e5e9705239e15c86ae2
2022-06-10 16:40:06 +02:00
Bartosz Dziewoński d6b5001580 Fire new 'wikipage.tableOfContents' hook to update TOC after save
Bug: T294950
Bug: T307480
Depends-On: I6cf76c870124c162dc1bcbc2f7e9ca0c5fdcd10e
Change-Id: Icaeda68ded94a04edef7a3629385eeb232048684
2022-06-09 11:31:50 -04:00
Reedy 9ee13d8471 Remove global class aliases
Change-Id: Id9b021f47d2ec181e5267e454a39ed3cafdec9d2
2022-06-06 17:23:23 +00:00
jenkins-bot df6b5fab51 Merge "Bump requested Parsoid HTML version to 2.4.0" 2022-05-25 00:01:18 +00:00
jenkins-bot bb7f777ffe Merge "Zero-configuration VisualEditor for mainline" 2022-05-25 00:01:15 +00:00
Tim Starling b9b6695c5a Use new ResourceLoader namespace
Extensions using Phan need to be updated simultaneously with core due
to T308443.

Bug: T308718
Depends-On: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
Change-Id: I9a20c25b9cea26e1fbe0f0434a0800632e9e0fc7
2022-05-24 22:59:39 +00:00
C. Scott Ananian ede9ffbd43 Bump requested Parsoid HTML version to 2.4.0
Visual Editor currently requests MediaWiki DOM version 2.0.0
when talking to Parsoid.  Since Parsoid treats that as a request
for 2.4.0, its current version, and Parsoid doesn't have a
2.4.0->2.0.0 downgrade path, passing the latest Parsoid version
(2.4.0) should make no difference in practice -- but would better
match current reality.

Change-Id: Ia2bc0c1981db6f573a69fb1910cef4304c80ae00
2022-05-20 15:01:09 -04:00
C. Scott Ananian 57dc7aa630 Zero-configuration VisualEditor for mainline
Now that Parsoid's ServiceWorkers have been merged to core, this adds
support for "zero configuration Visual Editor" to the master branch.
Like earlier zero-conf work, this does not use RESTBase for stashing
or for reliable selective serialization.  Future integration work
with ParserCache will reintroduce this functionality.  Nevertheless,
this implementation should have feature parity with the "loopback interface"
zero conf VE we've been shipping since 1.35.

Bug: T305108
Change-Id: I7b5b4a6d16b07914f947cbaf498ad1d3cf2447a5
2022-05-20 15:01:09 -04:00
Arlo Breault d8aa99e35c Stop passing scrub_wikitext
It's no longer optional in Parsoid.

Bug: T297298
Change-Id: Ice36f4f4b82b0286799e9eedd164ca8d2dfc2b2e
2022-05-17 19:51:17 -04:00
Timo Tijhof 54d44ccb6c ApiParsoidTrait: Log trace as 'exception.trace' instead of 'trace'
This ensures proper redacting, and consistent discovery and formatting
for Logstash queries.

Bug: T233342
Change-Id: I9a2a96793a5b7669648d222a0d472c15c09b84d3
2022-05-15 20:21:34 +00:00
jenkins-bot 2861442874 Merge "[doc only] Update comment in ApiParsoidTrait which mentions renamed file" 2022-05-11 13:22:47 +00:00
C. Scott Ananian 26df6d45c2 [doc only] Update comment in ApiParsoidTrait which mentions renamed file
This file was moved in 3f0f302577
(July 2019).

Change-Id: I310f8ad171cb927b93f61d4a7677741c3cb8faf1
2022-05-10 20:31:24 -04:00
Bartosz Dziewoński 4ebf2ae8bf Restore global context fiddling to fix FlaggedRevs edit notices and checkboxes
Partially reverts aed5bcf7d0.

Bug: T307852
Change-Id: I6aee2266c6b4dce560196c87b518ac25a493623a
2022-05-11 00:08:41 +02:00
jenkins-bot e0da7b6c8c Merge "ApiVisualEditor: Inject WikiPageFactory, UserFactory & HookContainer" 2022-05-05 21:11:42 +00:00
Mark A. Hershberger 3022b0e4e6 Hooks::onRecentChangeSave: Don't pass null to explode(), avoiding PHP 8.1 deprecation
Change-Id: Iaf2ad6b37c86e1555aaffe6dd08d9e511b319256
2022-05-02 12:11:19 +00:00
Derick Alangi 189e09e382
ApiVisualEditor: Inject WikiPageFactory, UserFactory & HookContainer
Change-Id: I940d266e10fc76329bebcdf18ac991b01a2a7a4f
2022-04-29 12:16:59 +01:00
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
gerritbot 41fa36d7a9 Fix usage of ApiBase::PARAM_* deprecated constants
The ones that are replaced with ParamValidator

Bug: T275455
Change-Id: I9dc1a587ded43d7211b1518b0b34d8dbb29381bf
2022-04-04 01:30:46 +02:00
Kosta Harlan 9241add01e Allow hook implementations to modify params
This is needed because the $params array is then passed on to
ApiEditPage, so if the hook implementer wants to alter the data used
with the edit, it needs to be able to modify the $params.

See I494d72a42d9103c28c4d44077cfe0f1269fc7b00 for an example where
GrowthExperiments would like to modify the 'tags' parameter for an
edit.

Depends-On: Idd052281898f99e4f13f241d5633294b59b29329
Bug: T304747
Change-Id: Ia4842a1593028f5fa145de167ccf9b72efa81351
2022-03-29 11:31:30 +00: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 39e0e865e8 Fix handling of disabled 'mobileformat'
Boolean parameters must be omitted completely if they're false.

Bug: T303262
Change-Id: I007640b59cf0f7861c72804109e09c118c250e7c
2022-03-08 14:00:34 +01:00
C. Scott Ananian d8b3ea9561 Replace deprecated Sanitizer::removeHTMLtags() with safer ::removeSomeTags()
This also matches the current code in OutputPage::setPageTitle()

Depends-On: Ic864c01471c292f11799c4fbdac4d7d30b8bc50f
Change-Id: I018b34bb5f6e113056da9b04cc72d4318422adce
2022-03-04 14:30:47 -05:00
gerritbot 3f5108fd1e Change use of deprecated getLazyConnectionRef
Bug: T255493
Change-Id: Ic323d820547c126e91bf82cd884db9d28ffbad41
2022-03-04 17:24:00 +01:00
Matěj Suchánek 2d6b737209 Show correct button label in the missing summary notice
The button in the top-right corner says "Publish changes",
not "Publish page" (if you save an existing page).
Saving an existing page is more common then creating
a new one.

Change-Id: Ia9516932672820baa0344c77683836cc391cefc7
2022-03-01 10:57:26 +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
David Lynch 14f99d05fd Avoid undefined index for mobileformat
Bug: T302344
Change-Id: Icf051b6fdec627c6477a7b2abd1ba4ccd5b3a259
2022-02-22 21:23:07 +00:00
Ed Sanders 93a7f33989 ApiVisualEditorEdit: Pass useskin & mobileformat to ApiParse
Passing the useskin parameter ensures that output hooks are run
on the new page HTML. This already happens because we request
the 'subtitle' and 'categorieshtml' props which also trigger
skin mode (along with the 'headhtml' which we don't request).

However it is better for us to be explicit that we want the rendering
for a specific skin, rather than relying on these props to trigger
the correct mode.

Also pass through mobileformat param, which is added by a hook
in MobileFrontend.

Change-Id: I1cd2c5c5c13ae0b90cc32e441b453532343a434a
2022-02-18 16:59:07 +00:00
Ed Sanders 5f8c5144ca Remove 'Hook' from new hook's method name
Only the class name needs the -Hook suffix.

Change-Id: I8c600ddb24a9d3a33ed78501639032d98e1e575f
2022-02-14 23:26:05 +00:00
jenkins-bot 6df803a821 Merge "Introduce VisualEditorBeforeEditorHook" 2022-02-12 00:54:15 +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
Ed Sanders ef29801474 ApiParsoidTrait: Make $title optional as it is not required when $oldid set
Change-Id: I307b649bf69e72ee5ca58c394af40e31c860d463
2022-02-08 15:09:28 +00:00
jenkins-bot 934af1d42d Merge "ApiParsoidTrait: Add "@return never" for Phan" 2022-02-05 23:43:24 +00:00
Bartosz Dziewoński 72c68e9e65 Remove redundant Phan annotations
Change-Id: Ic87fcc132b310191b086ccf7facfdf262a544eb9
2022-02-05 16:55:42 +01:00
Bartosz Dziewoński 9e22d21c8e ApiParsoidTrait: Add "@return never" for Phan
Like in MediaWiki core in I895f70e82b3053a46cd44135b15437e6f82a07b2.

Change-Id: I3cc8f887534897153fdefb78a7f28de42ffdf217
2022-02-05 16:49:40 +01:00
Ed Sanders 02cfb4bf71 Introduce VisualEditorBeforeEditorHook
Extensions can return false in this hook to disable VE on specific pages.

Bug: T174180
Change-Id: I764843fcfc07149c50ae6af758df43ca454d3296
2022-02-01 17:57:27 +00:00
Ed Sanders ba739a143d Always enable visual diff when diffmode=visual
We already had a query string hack '?visualdiff' to enable
the feature, but I think the pre-dated the diffmode param.

Now we have the diffmode param, we can just enable the feature
whenever diffmode=visual. This makes posting test links much
simpler.

Keepd the 'visualdiff' param for backwards compatibility.

Change-Id: If777d7f2e6a3b1a1725f174d149cf9eab4535d85
2022-01-26 15:15:53 +00:00
Bartosz Dziewoński ec59e2ed42 VisualEditorDataModule: Generate definition summary without parsing wikitext
Adapted from code in DiscussionTools.

Bug: T189229
Change-Id: I206bb05d28d492d6ba2dd9d29cdbe94323d6bad9
2022-01-24 22:19:17 +00: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
Bartosz Dziewoński 011277f757 ApiVisualEditorEdit: Fix Phan build failure
Caused by cbfcf9e8a8b2d5aaef78d8900c2e373d350eba02 in MediaWiki core.

Change-Id: I251f44faa46376ecde49c87ccff65025f56ab7e8
2021-12-20 23:26:44 +01:00
Bartosz Dziewoński b733e74d2f Check VisualEditorDisableForAnons in getEditPageEditor()
Other wikis with this setting only worked correctly, because the
wikitext editor was the default one anyway.

Bug: T296269
Change-Id: I58057320231471bc55d1e1b2fdfd0af55777c536
2021-12-09 20:41:40 +01:00
Roman Stolar 4fc6ea3f41 Avoid using User::getOption
Remove using of User:getOption since this method will be hard-deprecated. Now it is soft-deprecated

Bug: T296083
Change-Id: Ic177a170fd3c72ebbb80da60dc8597285ab5e023
2021-11-25 18:48:50 +02:00
Cole White 8b5bc61f43 log restbase response body as attribute of response object
Eliminates a source of log indexing failures.

Bug: T239458
Change-Id: I4f1cc06cdbd7e7ce02575b755aff6e9f7f9a8767
2021-11-04 15:27:07 -06: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
Bartosz Dziewoński 4e2318f2f0 Fix value of 'namespacesWithSubpages' in wgVisualEditorConfig
After filtering the PHP array to only include the ids
of namespaces with subpages enabled, add an array_values()
call so that the ids are again indexed numerically beginning
from 0, which is needed for the array to be passed to the
JavaScript as an array rather than an object.

Bug: T293310
Follow-up: Ia0ecac71721eceed52cc90f39ecc560bdf1b7f9b
Change-Id: I45bb281314caf5da0b7836829eb44f858836566f
2021-10-13 23:50:39 +00:00
DannyS712 2984539f42 Refactor how namespaces with subpages are exposed to JavaScript
Instead of using an object mapping namespace ids to if they have
subpages enabled or not, pass an array of the namespaces where
subpages are enabled, reducing the size of the configuration that
gets loaded on all requests. Only requires a minor update to the
JavaScript that uses the value (check for array index instead of
object value).

Bug: T291729
Change-Id: Ia0ecac71721eceed52cc90f39ecc560bdf1b7f9b
2021-10-06 20:11:37 +00: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 267daeb6c6 Filter JavaScript namespacesWithSubpages to only existing namespaces
$wgNamespacesWithSubpages can include namespaces that
don't exist, no need to add them to the JavaScript configuration.

Bug: T291727
Change-Id: I1f4f3d2c2accb3d84f83262480616d05115f406c
2021-09-29 20:39:30 +00: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
DannyS712 e6a39d70ac Stop adding $wgSVGMaxSize to JavaScript config variables
The code that uses it is commented out

Bug: T291729
Follow-up: I7af2bc91524e832555b66f090a671672cd14f294
Change-Id: I4cceb9ca83a2274fa93783af3608b9486b773522
2021-09-27 18:45:08 +00:00
jenkins-bot f9c2159c7d Merge "Simplify some API PHP code where possible" 2021-09-07 14:54:05 +00:00
libraryupgrader db01666a88 build: Updating mediawiki/mediawiki-phan-config to 0.11.0
Change-Id: I18aeec0e77c9aacfc4df8de485a246416cc0ecd3
2021-09-05 00:16:17 +00:00
Thiemo Kreuz a1464bd617 Simplify some API PHP code where possible
Change-Id: I663d9f2a25c70d8d265a3217cd1d0ad6fbb1bb3e
2021-08-26 11:37:13 +02: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
Kosta Harlan f9ce087e67 ApiVisualEditorEdit: data-{plugin} is not multi
Specifying it as such creates a 0 based index for what is a single value
property. This wasn't noticed before because I6b81ea318f52e accessed the
request object directly instead of using $params. See also
I3baa1ebb66559 for how this bug manifested in GrowthExperiments.

Bug: T289652
Change-Id: Ife8350d1cea79fc1dd6f3cb040a7801b9fe6db91
2021-08-25 10:47:13 +02:00
jenkins-bot 46bccb570a Merge "Replace Content::preloadTransform call to ContentTransformer::preloadTransform" 2021-08-23 16:09:16 +00:00
Kosta Harlan b973ff3ee3 Introduce VisualEditorApiVisualEditorPreSaveHook
What:

Add a hook that runs before a save attempt is made in
ApiVisualEditorEdit. The hook receives the same data available in
ApiVisualEditorEdit, and implementations of the hook can modify the API
response.

Why:

VE plugins may send additional data when saving an edit, and extensions
might want to prevent the save from taking place based on that
additional data.

See for example the AddLink plugin in Ic8225933c9, where the save is
blocked if link suggestions don't exist in the database at save time.

Bug: T283109
Change-Id: I6b81ea318f52ec47661086d85b5cc242a3fcd0e4
2021-08-18 09:39:00 +02:00
Roman Stolar e6c93bfbda Replace Content::preloadTransform call to ContentTransformer::preloadTransform
Bug: T287157
Change-Id: I44ee0014ac50c9c5dc66543dcd045dd5a81ce37c
2021-08-17 16:53:49 +03:00
jenkins-bot 991e34c166 Merge "ApiVisualEditorEdit: inject services" 2021-08-11 20:08:42 +00: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 2fbd7f5c11 ApiVisualEditorEdit: inject services
This patch adds dependency injection for the ApiVisualEditorEdit api
module.

Change-Id: I4f75fc32ff422ca0e0f163add1346963eedcc635
2021-08-10 18:16:46 +00: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
libraryupgrader 30b68f3a74 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.1 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 1.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: Ia15aa76cb4abbfe42215532edf52b08c75f72034
2021-07-21 19:56:36 +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