Commit graph

149 commits

Author SHA1 Message Date
Ed Sanders df8feb6faf Move mobile context to bottom of page
Hidden behind ve.newMobileContext feature flag.

Bug: T204733
Depends-On: Id276686a0e82c12c457c81eaec9939722c65c7ec
Depends-On: Id5f7ead769dc30c0fbd2a8b8f6f6c4d68dcfabac
Change-Id: Ibd4b699dfe4bb9bcaec6898b6b82357eb287d128
2019-06-14 20:57:22 +00:00
Umherirrender e1442aa343 Add phan
Change-Id: I7352036536c1c8415b681f48f3ee0dcec315c035
2019-05-31 14:48:22 +00:00
Thalia cdb3b880af Use MediaWiki\Block\DatabaseBlock instead of Block
This follows the rename of the Block class in I6d96b63ca0.

Change-Id: Ib652feb34b7f10726ec775ff2929ca12ed66a8e1
2019-05-31 15:34:00 +01:00
Bartosz Dziewoński 8ae4925676 Allow switching from WTE to VE with changes in non-RESTBase mode
* Change the query in ve.init.mw.ArticleTargetLoader#requestParsoidData
  so that in non-RESTBase mode with wikitext it still returns the
  metadata required to initialize the editor, using the backend API
  code added in I1b35b28e428a1f86d2e34d90ddbe73361ce14818. This fixes
  the exception from T222312.

* Introduce new configuration option $wgVisualEditorAllowLossySwitching
  to control this feature. It is enabled by default, fixing T214542.
  We allow it to be disabled because switching in non-RESTBase mode may
  cause "dirty diffs" (non-semantic changes to the wikitext), which are
  undesirable on wikis where users carefully review all changes.

Bug: T214542
Bug: T222312
Change-Id: I58879cba5612002c70c24731306214d2577c2c52
2019-05-30 20:18:53 +02:00
Umherirrender c9c4b68d25 Remove class_exists by ExtensionRegistry check for ConfirmEdit extension
Change-Id: I6ffb1842600316f2a6309a0028e96e75fe75f0c8
2019-05-29 12:10:02 -07:00
Ed Sanders 4a692e762d Special-case redlink URLs to load preferred editor
In general action=edit could be bound to a wikitext-specific
edit link, but in the case of redlinks we can use the
preferred editor instead.

Bug: T223793
Change-Id: Ib0851e9e2ce441ae93311153801e2c3de0a2063d
2019-05-26 17:55:38 +01:00
jenkins-bot e6d885789e Merge "Check if page is really editable and call #setReadOnly accordingly" 2019-05-18 18:10:59 +00:00
Bartosz Dziewoński 222ada6a8e VisualEditorHooks: Mark the 'preview' parameter as unsupported
We don't currently support it in NWE. It has a very different design
for previews that wouldn't really do what users expect. Let the old
editor handle this.

Bug: T195914
Change-Id: If0c0312347c212447bd8da7336c80bd4a1cb246a
2019-05-18 19:08:31 +02:00
Bartosz Dziewoński b9835f75d3 Check if page is really editable and call #setReadOnly accordingly
There are various circumstances where the wgIsProbablyEditable check
gives incorrect results (hence the 'probably'):

* User is blocked (T111217)
* Page is protected from creation (T173763)
* Page is transcluded on a cascade-protected page (T217217)

Bug: T111217
Bug: T173763
Bug: T217217
Change-Id: I7df8909c31f29d2e7521bef8612c27cb61146a4d
2019-05-18 17:23:31 +02:00
Ed Sanders 3285b7dbe5 Initialize $restbaseHeaders to null
Bug: T223281
Change-Id: I8bead40c35323cd4082f55ac529f900403f76f37
2019-05-14 16:07:22 +01:00
Bartosz Dziewoński a76d3daf54 DesktopArticleTarget.init: Allow veaction=edit to override namespace settings
Prior to 80bfbfc54b this worked by
accident, and with a number of bugs depending on your settings (see
T219457). It turns out that Wikipedia users have invented various
workflows that depended on this bug (mostly involving sandbox pages in
namespaces where VE is not enabled). Restore it as a supported
feature, and in a way that avoids the problems it previously caused.

Bug: T221892
Change-Id: I62714b6f2905efd1d1b34c7a13b9917cb6c609fc
2019-05-14 00:18:47 +02:00
Bartosz Dziewoński e48e7d95ec VisualEditorHooks: Use isVisualAvailable() when changing tabs/editsections
Change-Id: I93f00005eb3f58302d46c14259016c4cee625a18
2019-05-14 00:18:35 +02:00
Ed Sanders 3a4822c2fe Section switch from wikitext to VE
Use an API 'parse' call with a sectionid to trigger
a full document expansion using replaceSectionAtRev.

Then send this off the RESTBase to convert to HTML
and statsh.

Ensure the etag is passed back to the API response.

Bug: T117716
Bug: T223023
Change-Id: I1b35b28e428a1f86d2e34d90ddbe73361ce14818
2019-05-13 19:49:10 +01:00
daniel a15875e247 Add forward compat hack for getBlockInfo/getBlockAsResultStructure
This is necessary to allow the unmitigated removal of
ApiQueryUserInfo::getBlockInfo to be fixed. See discussion on
I84ed21641c44b2f65.

Change-Id: I9f40666a31bd4af50762c197c2ce5bf089a5e68c
2019-05-10 22:08:36 +02:00
jenkins-bot bc5b0c93dd Merge "Replace usage of deprecated ConfigFactory::getDefaultInstance()" 2019-05-08 22:27:31 +00:00
Bartosz Dziewoński 636531808c ApiVisualEditor: Fix use of getBlockInfo()
The method ApiQueryUserInfo::getBlockInfo() was removed in unannounced
breaking change in MW core: I84ed21641c44b2f65ebe1980b0893d1846db3b34.
Apparently we're supposed to use the method from ApiBlockInfoTrait now.

Bug: T209599
Change-Id: I7ab5492310980b1527c7329faf65655330b8bef0
2019-05-08 22:36:38 +02:00
Marko Obrovac c32bce5add ArticleTargetLoader: Add stash=true query param to RB HTML fetching
RESTBase is changing the way it is storing HTML/data-parsoid renders. In
order to still support VE (and other editors) with quick access to HTML
and matching data-parsoid (needed later for transforming the modified
HTML to wikitext), VE now needs to let RESTBase know it intends to
perform a transformation call later on. In that case, RESTBase will make
sure to keep the matching data-aprsoid around for long enough.

Bug: T222639
Change-Id: I02672e29bd0f331794fd77d9e56f9cc6822d9b9e
2019-05-08 13:30:01 +02:00
Derick Alangi cf663a40b4 Replace usage of deprecated ConfigFactory::getDefaultInstance()
Is replaced by MediaWikiServices::getInstance()->getConfigFactory().
Also, did a few minor cleanups where necessary such as; objects are
passed as references by default etc.

Change-Id: I42cd242ebdbc0b091a99e771289020d498bf2bba
2019-05-04 22:02:29 +01:00
jenkins-bot f6a8a097f2 Merge "DesktopArticleTargetInitModule: Avoid expensive $msg->exists check" 2019-05-01 17:28:00 +00:00
Ed Sanders fae9fcb70c ApiVisualEditor: Return structured block info as well as formatted notice
Mobile builds its own block message from the block information,
rather than using parseAsBlock.

Bug: T209599
Change-Id: I8b200f258b50f7048aded22ec7ab81a49937c5a9
2019-04-30 20:41:03 +00:00
jenkins-bot fa50329f62 Merge "Use PageEditStash services instead of static methods" 2019-04-24 15:11:19 +00:00
Aaron Schulz e2fa08f0f8 Use PageEditStash services instead of static methods
Change-Id: I1bcda750a22dcacfffa0f7400411a7653806a82e
2019-04-23 12:45:21 -07:00
Dayllan Maza 96de1353d3 Remove block notice tracking
This is a clean up after collecting the necessary data related to
blocks and how often users see the block notices

See: https://phabricator.wikimedia.org/T189724

Bug: T214214
Change-Id: I532a0cd95009109ba25caa8dd31badd5c1900da7
2019-04-23 11:31:37 -04:00
Timo Tijhof 139b5b879a DesktopArticleTargetInitModule: Avoid expensive $msg->exists check
This check currently requires LCStore, MessageCache, and (sometimes)
Database to involved to check whether the message and/or local override
exist.

Using `useDatabase(false)` should take away most of this cost
by no longer performing the multiple Memcached/Database roundtrips,
and leaving only a cheap in-process check on LCStore.

Bug: T221294
Change-Id: I6bf47cd84cdf9bfdd63bee0a613425bb79595e4f
2019-04-17 23:12:53 +01:00
jenkins-bot 9a8a0592de Merge "VisualEditorHooks: Remove redundant $resourceModules check" 2019-04-17 19:03:12 +00:00
Timo Tijhof ff5f688405 DataModule: Use module->getConfig instead of rl->getConfig
The latter is being deprecated as of I74a9535918e because it was
almost never used intentionally. When module objects are created,
the appropriate context object is injected via setConfig. That is
the one the modules should use.

The context object has a reference to the ResourceLoader object
(although unsure why actually), but shouldn't be used for this
purpose as there could be a 1 to many relationships further down
towards modules.

Change-Id: Icab0f12141a46476618f984d4548a82fdae33275
2019-04-17 17:33:53 +00:00
Timo Tijhof afdd1b5fca VisualEditorHooks: Remove redundant $resourceModules check
For a while now, the 'ResourceLoaderRegisterModules' hook is
the last oppertunity to register modules. Therefore, the
isModuleRegistered() check covers everything it needs to.

In addition, at this point modifications to ResourceModules would
be ignored even if it did contain additional entries.

Change-Id: I77714fca0f561f5817a45dd3be5fd8d3ba42f969
2019-04-17 15:20:13 +01:00
Timo Tijhof ef36f4b0a1 Move usePageImages/usePageDescriptions from page conf to site conf
These do not vary by user or page, and can thus be loaded asynchronously
via the startup module, rather than blocking rendering and fetching
of modules on all pages.

In a future change, it might be better to go a step further and bundle
these with a module so that they only load as-needed instead of still
on all page views, but this should be an improvement nonetheless.

Change-Id: Icae3712ac5546a90bc7ffd787b0f3285dff6a26f
2019-04-17 00:10:27 +01:00
Timo Tijhof cc599c2e36 init: Bundle wgVisualEditorUnsupportedEditParams with DesktopArticleTarget.init
Bug: T219342
Change-Id: I4b5a048779bd4b957cc5d99c3a7686363ffb3df9
2019-04-16 16:33:53 +02:00
Reedy 5a5af75c85 s/PreferencesForm/PreferencesFormOOUI/
Change-Id: I44a99ef1905c7c438da159d133b956d3488c0092
2019-04-14 01:47:03 +01:00
jenkins-bot 1b2c1425ee Merge "Allow external link pasting to be enabled by config" 2019-04-09 16:05:26 +00:00
James D. Forrester 4df2558910 Hooks: Don't set wgVisualEditorToolbarScrollOffset in RL when 0
We should also move this to packageFiles, but that's more work.

Bug: T220158
Change-Id: I438dc13802d744877921dc612b16cc22b0713e00
2019-04-05 11:42:05 -07:00
Aaron Schulz 1a5fc05dda Avoid keeping excess keys from storeInSerializationCache() in cache
Remove overkill $VisualEditorSerializationCacheTimeout config setting
and just use a simple constant instead (convention over configuration).

Bug: T203786
Change-Id: I94424088a03a3262fcea30132883a612465c546e
2019-04-03 18:34:07 +00:00
jenkins-bot aeeffb912a Merge "Treat ambiguous values in $wgVisualEditorAvailableNamespaces as names" 2019-04-02 15:20:59 +00:00
Derick Alangi 37e978d169 SpecialCollabPad: Remove unused variable $request
Change-Id: Ie5cce0771c2b7f1f5a521d3129deb2063b5cbf5b
2019-04-01 23:08:02 +01:00
Bartosz Dziewoński 018464a096 Treat ambiguous values in $wgVisualEditorAvailableNamespaces as names
The config option can contain either namespace names or IDs.

Bug: T219562
Change-Id: I6b3706ea7e26f69427ffac1603b093bcb8fdbd03
2019-03-29 01:08:03 +01:00
jenkins-bot d41366c452 Merge "Clean up serialization cache code a bit and add more metrics" 2019-03-28 17:49:51 +00:00
Aaron Schulz a56fbba6c3 Clean up serialization cache code a bit and add more metrics
Change-Id: Ib2024026a2b6f42ed0c56479a0cec2a8cbd1e3bc
2019-03-28 00:26:37 +00:00
Bartosz Dziewoński 21e9db7d13 Respect user preference for default thumbnail size while editing
Bug: T69047
Change-Id: Ibf90d290df5634cd89651a427a6aa1c6f9d7a553
2019-03-26 22:15:26 +01:00
Bartosz Dziewoński a5c5257e71 Directly call action=query&prop=langlinks from JS rather than PHP wrapper
When this code was written in 2013 (1a5bdd5bd2),
the langlinks API did not have a way to return the language names (autonyms).
This has been added in 2014 (4ba3a9aea96ee21c035c69999be23580e23f4e0a).

Change-Id: I70edb846d94b1108b079caf5915532234190da8f
2019-03-18 23:27:44 +01:00
Bartosz Dziewoński c0ab5133eb ApiVisualEditor: Fix PHP warning caused by unexpected API metadata
Bug: T218464
Change-Id: I272ca718932cb9cd57d121c9f564c64e11f9deff
2019-03-18 23:01:09 +01:00
Umherirrender de8b4b5d29 Use php null coalesce operator ??
Change-Id: I756fa99084cbb86357ac840b3338d296863eecc4
2019-03-12 21:27:47 +01:00
jenkins-bot f501a5238b Merge "Fix return type of ApiVisualEditorEdit::saveWikitext" 2019-03-08 20:50:04 +00:00
jenkins-bot 476ffbba68 Merge "Use DerivativeContext in ApiVisualEditorEdit" 2019-03-04 19:09:19 +00:00
Umherirrender c9a3bf9fa5 Use DerivativeContext in ApiVisualEditorEdit
Using DerivativeContext also makes the code easier to read.
getContext() returns an IContextSource, in this interface has no
setRequest() method and this can fail for some kinds of IContextSource.
$view is a ContextSource, which implements setContext().
This also allows us pass in a new context with the right request object,
and also to set the title so we don't have different titles
on $view and the main context.

Change-Id: Ia575cd6163defeb423a542e342034cac5eb6108c
2019-03-04 18:36:47 +00:00
Reedy 2fb0ed0269 Use ExtensionRegistry rather than class_exists
Change-Id: I6e8fb5e5f3a9ef5b8ba4787c43ee1216ea03bd7e
2019-03-02 23:29:09 +00:00
Umherirrender a07ad01594 Use ::class for class name resolution
Available since php5.5

Change-Id: I9392155193275d20a82bde8eb7964d466e190f6b
2019-03-02 23:46:12 +01:00
Umherirrender 8c1eda388e Fix return type of ApiVisualEditorEdit::saveWikitext
Change-Id: I523d8097b39d80fc7082c64009b49b36f8a296a7
2019-03-02 18:04:14 +00:00
Ed Sanders 2092529fb1 Allow external link pasting to be enabled by config
Bug: T129546
Change-Id: I3346c842cf56fb79fb65a8bd7d716c22134636b9
2019-02-27 19:54:55 +00:00
Ed Sanders e3bb0b9e8b ApiVisualEditor: Separate out templatesUsed from metadata
Generating the templatesUsed list is relative slow, and is only
used in an obscure part of the editor, so only generate it when
needed.

Bug: T209078
Change-Id: I1cecdad65b80c4c9b1746e752ea4b41bc0fc0037
2019-02-25 13:01:43 +00:00