Topic on Help talk:Extension:ParserFunctions

ifexist a registered user

3
190.242.129.62 (talkcontribs)

the magic word #ifexist it will always show the second parameter if the first parameter is put "Media:" and then an existing media file, instead if "File:" is put it will show the third parameter if there is no description, however, I don't know if it's possible with users, the user:Google~mediawikiwiki is registered, but as you can see, the user page doesn't exist because it hasn't been created, I've tried with the special pages (logs, listusers and contributions) with non-existent users, but it always gives the second parameter, is there a way it can shows the third parameter if the specified user on the first parameter doesn't exist?

RobinHood70 (talkcontribs)

Currently, there's no way to determine whether a user is registered or not via a parser function, and I can't think of any tricky ways around that limitation, either.

Verdy p (talkcontribs)

Media files are a bit special because they can possibly not exist on the local wiki but may exist in a shared wiki like Commons. #ifexist does not support testing on other wikis (it is much most costly then testing on a local wiki, as it requires using a REST API from another wiki. Usually, links to media files are just there to render an "external" link to the media file as is then not tested. Using "Media:" in #ifexist to conditionally use "File:" to render it is not warrantied to work, except if the file is hosted on the local wiki (e.g. a file in English Wikipedia that is not importable and replaceable by a file with the same name on Commons).

When using external wikis, the parser will not invoke the thumbnail renderer of the local wiki, but will just request the "file:" from the external wiki. However there's a delay for that external renderer to provide a reply. Whereas #ifexist can only perform synchronous requests (in a short completion time).

To support testing files on another wiki with #ifexist, it would require an optional parameter asking if it wants to test another wiki by performing an asynchronous request; the problem is that Mediawiki does not support asynchronous requests, whose completion time is unpredictable. The same would be true idf one wants to used "shared" templates or modules.

So #ifexist is not tuned to allow asynchronous requests, that would block the rendering of the current page being parsed. I have no idea how this could work. #ifexist is supposed to run on the same database as the page being rendered. But if it was working we could test external links to any page on any wiki, using wikilinks with interwikis. Worse, the result would not be cachable in the parser cache; even if that external site has the shard resource, you don't know really how and when it will return the content (you don't even know what will be its metadata, notably the media type and size, which may change at any time (there's no mechanic for cache synchronization between different wikis).

When you use a shared image, the parser assumes that the external file exists and that the external site will generate a thumbnail with the requested size and media type. The actual request to the external server is then not made by the parser and not cached, but made on client side, by the web browser of the visitor, making its own asynchronous requests, with the external site making all the needed parsing and transform to HTML or a thumbnail image, so that the local wiki will never parse the result

Reply to "ifexist a registered user"