Page MenuHomePhabricator

Unable to use #autoedit with File: namespace, even after specifying NS_FILE with $wgPageFormsAutoeditNamespaces[]
Open, Needs TriagePublic



MediaWiki 1.31.1
Page Forms 4.6 (71f42d6) 11:08, September 4, 2019

From the Page Forms documentation, I understand that by default #autoedit is only available for the "main" namespace. This can be changed by modifying the global variable $wgPageFormsAutoeditNamespaces in LocalSettings.php. I am trying to use #autoedit with images in the File: namespace, and this is was my PHP modification: $wgPageFormsAutoeditNamespaces[] = NS_FILE; but I keep encountering this error:

VM100:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0

at parse (<anonymous>)
at Function.jQuery.parseJSON

CC: @Yaron_Koren

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 4 2020, 6:37 PM
Madrigal84 updated the task description. (Show Details)Oct 4 2020, 6:39 PM
Madrigal84 added a subscriber: Yaron_Koren.

@Madrigal84 - sorry for not responding to this issue before. I just tried #autoedit with a page in the File: namespace, and it worked fine for me. Maybe you should upgrade to a newer version of Page Forms? Your version came out over a year ago, and this issue might have been fixed since then.

@Yaron_Koren I upgraded to 4.9.5, but I am still encountering the same issue. I call the #autoedit function from a cargo query, and assign |target=File:{{{1}}}, where {{{1}}} is the image _pageTitle. Removing File: form target does not work since it saves to a page with the same name as the file, but not in the File: namespace.

LocalSettings is using this global variable: $wgPageFormsAutoeditNamespaces[] = NS_FILE;

My colleague, @Longphile, reported this issue here: Extension talk:Page Forms

Could it be because the Cargo query is somehow messing up one or more of the characters? What happens if you put in that same #autoedit call directly on the page, and click on that?


The issue was the $wgUrlProtocols global variable. We originally set file: without trailing slashes.

In MediaWiki 1.20.2+, adding "file:" without trailing slashes to $wgUrlProtocols will break image embedding using the [[File:Image.jpg]] syntax. This is a known bug related to a change that made URL protocol matching case-insensitive. As a workaround, use "file://" instead of "file:" as shown below.

This was the solution:
$wgUrlProtocols[] = "file://";

Change 634104 had a related patch set uploaded (by Yaron Koren; owner: Yaron Koren):
[mediawiki/extensions/PageForms@master] Fix for results display for #autoedit of file pages

Change 634104 merged by jenkins-bot:
[mediawiki/extensions/PageForms@master] Fix for results display for #autoedit of file pages

@Madrigal84 - I'm not sure I understand the problem, but I just checked in an improvement so that, after the #autoedit link is clicked, it displays a regular link to the file page and not the image itself (which was never the intention). Does that fix this issue?