Commit graph

442 commits

Author SHA1 Message Date
Bartosz Dziewoński 8418686893 ApiParsoidTrait: Remove unused abstract method dieStatus
No longer needed after 1177e677e6.

Change-Id: Ie77ff40c6c98208e99efe151ec18544644a3c9b4
2022-09-28 16:00:24 +00:00
Bartosz Dziewoński 209aaf6943 ParsoidClient: Fix getPageHtml() $targetLanguage param inconsistencies
* DirectParsoidClient: Actually allow null to be provided.
  Previously we tried to call methods on it unconditionally.

* VRSParsoidClient: Require the param to be provided (even if null).
  No reason to diverge from the interface, which requires it.

Change-Id: Id9a450dc8b8eb3e82cf87718b96975e5a3c6180c
2022-09-26 22:52:31 +02:00
daniel 0d833c3de1 ParsoidClient: rename language parameter
The language parameter in the ParsoidClient is always the desired output
language.

Change-Id: I10bec964b16fb041d5acfc63f38511e545adafc4
2022-09-26 22:46:22 +02:00
daniel 4c1ec8fc40 ParsoidClient: error should be array or null
This follows up the initial fix with additional sanitation and a
regression test. See I21c7a2b2541061a858a9791a2cb12866acd38dc5.

Bug: T318083
Change-Id: I4e433e711c068336a888f4aafa243455764fd710
2022-09-20 21:05:51 +02:00
Alexander Vorwerk 87ff7a5fec Only die when error string is not empty
Bug: T318083
Change-Id: I21c7a2b2541061a858a9791a2cb12866acd38dc5
2022-09-19 13:25:37 +00:00
daniel 1177e677e6 Remove redundant ParsoidHelper class from VE
All code that used to live in ParsoidHelper has been moved to
VisualEditorParsoidClientFactory and VRSParsoidClient.
ParsoidHelper is no longer needed.

Change-Id: I21c4a8cd86f8d085e75a601ed6d2509dedd75d42
2022-09-15 19:23:05 +00:00
daniel 0cd6c90d5a Extract RESTbase client code into VRSParsoidClient.
This makes the "direct" client and the VRS based client
implement the same interface, so the caller doesn't have to know
which one it is using.

It looks like ParsoidHelper will not be needed if we use this approach.

Change-Id: Ib1c1d7355951fc0765227dd01a9edfc554fc448d
2022-09-14 18:20:36 +01:00
jenkins-bot 47cba98037 Merge "Improve some API param docs and validation" 2022-09-06 22:40:13 +00:00
Derick Alangi 8bfe88b8b1 ParsoidHelper: Make VisualEditorParsoidClientFactory required
In order to make this interface cleaner and not promote the
use of optional parameters when not needed, make the factory
required so that callers should worry about it and not overwork
the helper.

In this case, DiscussionTools extension is already using this
interface and has the factory injected appropriately.

Depends-On: If682af406c0fc7a9eca106eb3ebd95e6c14baddd
Change-Id: I836c0ad73687d8b99d1e067a5c3a3e512b4bd37a
2022-09-06 21:44:29 +01:00
Derick Alangi 8c458e78b4 ParsoidHelper: Remove unnecessary $config
Getting the correct client is now done via the VisualEditorParsoidClientFactory
so this is no longer needed. Follow-up of: I787c0afb227308aab56770d.

Depends-On: I4b9e7362a1bf1b4f224c8c652d40851a18c19824
Change-Id: I175aef2326a0d784fb8211542a3fe90cbf6c6d08
2022-09-06 12:05:39 +00:00
Derick Alangi b029fd8ede Introduce VisualEditorParsoidClientFactory
This patch introduces a factory service for creating VE Parsoid
clients.

NOTE: This patch also injects a GlobalIdGenerator to the client
 and avoids usage of deprecated UIDGenerator class.

Change-Id: I787c0afb227308aab56770d14d62e08eb0084a6c
2022-09-06 12:47:43 +01:00
Bartosz Dziewoński 0ade4be5b6 Restore the $oldid condition for funny ETag logging
Follow-up to 951348dbbf. When creating a
new page on a RESTBase wiki, ETag is actually expected, but it will be
in a different format; the code comment was wrong.

Bug: T316969
Change-Id: Ia36488616ced70b900d2e67ce8e28993cc2c7514
2022-09-03 05:06:44 +02:00
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