Page MenuHomePhabricator

Media links get mangled when edited with VisualEditor if short URLs are not set up(?)
Open, Needs TriagePublicBUG REPORT

Description

MediaWiki 1.35 using new internal parsoid service (i.e no external rest or pasrsoid service)

Steps to Reproduce:

  • Upload a file (or find and already uploaded file). For our purpose, the file name will be essai.jpg
  • Create a page
  • Switch to source mode
  • Create a media link:
[[Media:essai.jpg|essai.jpg]]
  • Save
  • Edit page with VE
  • Do something innocuous (e.g. add a space) to be able to save the page. Save it

Actual Results:

The media link is broken after the page has been edited with VE

Expected Results:

The media link should be working since it has not been modified

Event Timeline

The following experimental modification (removing "index.php?title=" from the resource attribute) seems to fix the issue for my installation:

diff --git a/extensions/VisualEditor/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js b/extensions/VisualEditor/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
index fdf9a01b..ce1acf10 100644
--- a/extensions/VisualEditor/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
+++ b/extensions/VisualEditor/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js
@@ -38,8 +38,8 @@ ve.dm.MWInternalLinkAnnotation.static.allowedRdfaTypes = [ 'mw:Error' ];
 ve.dm.MWInternalLinkAnnotation.static.toDataElement = function ( domElements, converter ) {
        var targetData,
                resource = domElements[ 0 ].getAttribute( 'resource' );
-
        if ( resource ) {
+               resource = resource.replace("index.php%3Ftitle=","");
                targetData = mw.libs.ve.parseParsoidResourceName( resource );
        } else {
                targetData = mw.libs.ve.getTargetDataFromHref(

Also, although normal links do not get corrupted in the same way, editing them still tags the "index.php?title=" in the input box as an invalid link (see screenshot below)

20201009VElinkediting.PNG (221×428 px, 8 KB)

Parsoid and VisualEditor basically assume that you have short URLs set up on your wiki (or at least that you have $wgUsePathInfo enabled). I've recently ran into similar problems (https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/623873 / T261711). This would probably take lots of work to fix and I don't really see it happening… Sorry.

Parsoid and VisualEditor basically assume that you have short URLs set up on your wiki (or at least that you have $wgUsePathInfo enabled). I've recently ran into similar problems (https://gerrit.wikimedia.org/r/c/mediawiki/services/parsoid/+/623873 / T261711). This would probably take lots of work to fix and I don't really see it happening… Sorry.

It used to be working in 1.33...I am not even talking about media link, just normal links.

ppelberg moved this task from To Triage to Triaged on the VisualEditor board.
ppelberg moved this task from Untriaged to Freezer on the Editing-team board.
Jdforrester-WMF renamed this task from Media links get mangled when edited with VisualEditor to Media links get mangled when edited with VisualEditor if short URLs are not set up(?).Oct 15 2020, 4:16 PM