Page MenuHomePhabricator

mw.title.exists does not properly handle the Media: idiom used by #ifexist
Closed, ResolvedPublic

Description

The current version of the mw.title library as used on test2 does not properly handle the existence of non-local (Commons) files. Instead of a title object for "Media:<filename>" having a true "exists" value, as #ifexist does if a file by that name has been uploaded to the Commons, said "exists" value is false. Based on my quick inspection of the code, it appears that the library does not give special treatment to the Media: namespace, unlike the original parser function.

Example:

exampleFile = mw.title.new("Media:I-10.svg")
print(exampleFile.exists)

Expected result:
true

Actual result:
false


Version: unspecified
Severity: normal

Details

Reference
bz45774

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 1:22 AM
bzimport set Reference to bz45774.

Merged by Aaron Schulz on the 8th. Is this bug fixed now?

I won't know until the test wiki is updated. Should I install a local copy to test it out?

Should be fixed now; if not, the bug can always be reopened.

@Alexander Jones: You certainly could install a local copy to test it out, such a local copy is *very* useful for MediaWiki development and testing. But you should also be able to test this in Beta Labs, which among other things has http://en.wikipedia.beta.wmflabs.org/ set up with a configuration equivalent to enwiki but running the latest git master.

@Brad Jorsch: Said wiki doesn't have access to Commons, so that's a no-go. I'll work on installing Scribunto on my local wiki (which does have access to Commons) tomorrow.

(In reply to comment #5)

Said wiki doesn't have access to Commons, so that's a no-go. I'll
work on installing Scribunto on my local wiki (which does have access to
Commons) tomorrow.

It does have access to the Beta version of Commons, http://commons.wikimedia.beta.wmflabs.org/.

If you use an image there, e.g. http://commons.wikimedia.beta.wmflabs.org/wiki/File:500px-IP.svg.png, it appears to work correctly in a quick test.