Page MenuHomePhabricator

#ifexist parser function returns false for image pages from shared repository (Commons)
Closed, ResolvedPublic

Description

Author: hugo.lpz

Description:
Not expected result with a fonction {{ifexist: ... | then ... | or... }}.
The function work perfectly on commons, see
http://commons.wikimedia.org/wiki/User:Yug/Test , but doesn't work to call the
same images on others projects.

After an enquery, it appear :

  1. that's not a chinese character problem.
  2. that's only with Namespace "Image:"... issue.
  3. {{ifexist: work only for page "edited" on the mediawikiproject. In exemple,

the Image:Wikipedia.png is not on wikitionary-fr , but the page was edited, so
the function {{ifexist: will work. If I delete the 2 edit, the pic is still
visible on wikitionary-fr, but the page does not "exist", and the function
{{ifexist: will not work.


Version: unspecified
Severity: normal
URL: http://commons.wikimedia.org/wiki/User:Yug/Test

Details

Reference
bz7985

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:27 PM
bzimport added a project: ParserFunctions.
bzimport set Reference to bz7985.
bzimport added a subscriber: Unknown Object (MLST).

this is not a bug, the ParserFunctions are defined as {{#function:...}}

hugo.lpz wrote:

I'm nowadays working on {{ifexist: function such as "if Image:Blabla.png exist,
then show "that", otherwise show "This image does not exist". For such purpose,
(I) need that mediawiki look if the IMAGE exist and not its "host page".

Use :

  • Build "if"-function-template about <b>Images</b> on the subprojects of wikimedia.
  • Then rename series of images without destroying subprojects' pages

Have we a solution ? Can we get an improvement ?

ayg wrote:

Read the links. The function was used correctly, so that at least doesn't make
it invalid. I'm busy today, but I'd guess the problem Yug is having is that
{{#ifexist:}} doesn't work for checking uploaded files, only for checking pages,
and it doesn't work for shared repositories like Commons.

robchur wrote:

(In reply to comment #3)

{{#ifexist:}} doesn't work for checking uploaded files, only for checking pages,
and it doesn't work for shared repositories like Commons.

That is indeed the case; the function was provided as a page existence check.

hugo.lpz wrote:

to Simetrical :
...
Exactly.

hugo.lpz wrote:

That is indeed the case; the function was provided as a page existence check.

So the need is not to fix this function, but to find which other function allow
to check uploaded files shared on commons.

Changed summary to describe the issue better.

In general we have page existence checks for the Image namespace overridden to act as existing for pages where an
image exists, whether local or on the shared repository. This makes things feel cleaner, as for all intents and
purposes they "exist" to someone poking at them.

I'm not sure whether it would be better to have #ifexist behave this way as well, or if a function specifically to
check for image existence might be better. I do hate feature creep, though. ;)

robchur wrote:

It would probably make sense to have #ifexist behave in that manner; it isn't
going to break existing uses, it reduces the amount of colon functions people
have to remember, and it's just plain sane to do it. If people use, e.g.
{{#ifexist:Image:Brion_shows_off_his_code.jpg}}, they're probably expecting it
to reflect the image's existence.

hugo.lpz wrote:

I think it's need to have two function for and Image wiki page :

  1. one for the page (edited/not edited), currently : {{#ifexist:
  2. one to check uploaded files, currently : no function avalable.

(In reply to comment #8)

It would probably make sense to have #ifexist behave in that manner; it isn't going to break existing uses, it
reduces the amount of colon functions people have to remember, and it's just plain sane to do it. If people use, e.g.
{{#ifexist:Image:Brion_shows_off_his_code.jpg}}, they're probably expecting it to reflect the image's existence.

On the other hand, the intuitive meaning of {{#ifexist}} equates to "is not a red-link". For images from commons,
should this meaning be correct? In other words, should there be a simple way to detect whether an image is available
but not local?

The suggested {{#ifexistfile}} {in comment #9) would seem to satisfy that possible requirement.

Patch implementing #ifimageexist

attachment ifimgexist.patch ignored as obsolete

robchur wrote:

I still think it makes more sense to alter the functionality of {{#ifexist}} to
deal with this situation; it means less colon functions to remember, and it
makes sense to fix the behaviour of the existing one rather than work around it
with a new one.

hugo.lpz wrote:

I suggested to have two differents function because of one situation :

Image:page edited + no image avalable.

if {{ifexist:}} check the uploaded page, how find such page ?

Except the need for such exeptional (minor) cases, I also think that just one
function make more sense.

hugo.lpz wrote:

[...]if {{ifexist:}} check the uploaded FILE, how [...]

robchur wrote:

Another option would be to allow the user to pass in Image as the namespace to
check the page's existence, and Media as the namespace when checking the actual
file's existence.

hugo.lpz wrote:

This seem to be a great deal. Then we have to show this information-distintion
clearly in one wiki-page.

Patch for ifexist

This patch will add a check if the namespace is NS_MEDIA, then we'll check the
file instead of it's page.

attachment ifexist.patch ignored as obsolete

robchur wrote:

Please observe existing code conventions. Some additional whitespace as used
elsewhere in the file makes things easier to read. That comment also doesn't
need to be so verbose; if anything, a one-liner will do.

hugo.lpz wrote:

So What should I use : {{ifexist:Media:Brion_shows_off_his_code.jpg}} ?

robchur wrote:

Yes. And tell that filthy Vibber bloke to put it away. ;)

hugo.lpz wrote:

Don't work for me in commons.
see :
http://commons.wikimedia.org/w/index.php?title=User%3AYug%2FTest&diff=3613915&oldid=3561268

I tryed for namespace : NS_MEDIA ; Media ; MEDIA ; Ns_media ; Ns_Media ; NS_Media ;
No one worl fine on commons.

robchur wrote:

It hasn't been applied to the software yet, let alone taken live.

hugo.lpz wrote:

O.o Ok, thanks for this quick answer. :]

(In reply to comment #10)

In other words, should there be a simple way to detect whether an image is available but not local?

Is this question answered with the new suggestion? In other words, would {{#ifexist:Media:example.jpg}} and
{{#ifexist:Image:example.jpg}} be TRUE and FALSE respectively if "example.jpg" were hosted at commons?

implementation

fixed whitespaces per Rob and fixed minor grammar in the comment.

Attached:

hugo.lpz wrote:

Please, when that work fine, show me the good syntaxe in this page :
http://fr.wiktionary.org/wiki/Utilisateur:Yug/Test
many thanks

hugo.lpz wrote:

Hello, please what is the situation of the bug ?

Is it already applied to the software ? what is the syntaxe ?

Can you show it there : http://fr.wiktionary.org/wiki/Utilisateur:Yug/Test please.

ayg wrote:

This feature has not yet been implemented. If it were implemented, it would be RESOLVED FIXED.

(In reply to comment #28)

This feature has not yet been implemented. If it were implemented, it would

be RESOLVED FIXED.

I have made an implementation, but it hasn't been reviewed or applied yet.

webmaster wrote:

Could someone review Carl's latest attachment? We might be able to add it to the extension...

hugo.lpz wrote:

REVIEW NEED ....(!)

Hello, someone may him finish this issue ?
I'm leaving Wikipedia for personnal reason, and they are some Wikidictionary users and Commons' user who are waiting a solution for this bug. Thanks to make your best,

[http://fr.wikipedia.org/wiki/Utilisateur:Michelet/Test : page showing that this issue is not applied ]

Regards,

Yug

hugo.lpz wrote:

Many Thanks !! When Will we be able to use it ?

(In reply to comment #33)

Many Thanks !! When Will we be able to use it ?

Whenever Brion gets around to updating the software Wikipedia runs. On your own wiki (if you have one), you can use it right now by checking out the source from SVN.

fearow00 wrote:

Wouldnt it make more sense to have ifexists on Image: return if there is a page there, and ifexists on Media if there is a file by that name available? It would make a bit more sense. Although the current way works fine :)

(In reply to comment #35)

Wouldnt it make more sense to have ifexists on Image: return if there is a page
there, and ifexists on Media if there is a file by that name available? It
would make a bit more sense. Although the current way works fine :)

That's exactly the behavior I committed yesterday.

hugo.lpz wrote:

hello,
the function still doesn't work for me. see http://commons.wikimedia.org/wiki/User:Micheletb/Test . can you give me a working example ? that will help me and the japanese wikibook a lot.

regards,

hugo.lpz wrote:

CLOSED ! many thanks ! that' s perfect now ! thanks to platonides !! I already sent message to some other interested users working on the japanese wikibook to use this function ;)

many thanks to every one !