Page MenuHomePhabricator

cywiki bad wikitext
Closed, ResolvedPublic

Description

cywiki has wikitext of this form on lots of pages:

{{First word|{{#invoke:Wikidata|getImages|P242|FETCH_WIKIDATA}}|sep=]}}]] ..

The inner {{#invoke .. }} generates a well-formed image link ([[..]]) .. and the {{First word|...|sep=]}} strips the trailing ]] and then the top-level puts that ]] back in. First word invokes a lua module to do regexp-match based on the sep and returns a matching string. Of course, Parsoid doesn't support this because it doesn't support concatenation of two strings to be treated as a link. I don't understand why they have this bizarre usage (presumably at some point they appended additional top-level image options?). But, in any case, for their current usage, it looks like they can simply get rid of First word wrapping around the getImages wikidata call and be done.

This insource search shows ~18K pages affected. As far as I can tell, they are all automatically-generated articles written by [[User:BOT-Twm Crys]] based on town/location information in wikidata.

Replacing:

{{First word|{{#invoke:Wikidata|getImages|P242|FETCH_WIKIDATA}}|sep=]}}]] ..

with just

{{#invoke:Wikidata|getImages|P242|FETCH_WIKIDATA}}

ought to fix the parsoid compatibility issues.

Event Timeline

I'm guessing the {{First word... business was originally intended to let you add custom image options to the result of the getImages call? But this isn't actually used anywhere, and if you wanted to add extra options you should (IMO) just pass them to the Wikidata module, rather than do this song-and-dance with the tokens.

Wikidata is sufficiently general-but-focused-on-Wikidata (and widespread) that fixing it locally would fork a module that is seen as not needing to care about images.

I am not surprised this kind of hack exists but I don't think the solution is so simple as "just do X".

FWIW. These pages all seem to be created by a bot. I ask the bot operator if it's okay to fix them.

Hi, and thanks for the heads up, Ladsgroup.
Yes, I run [[User:BOT-Twm Crys]].
I'm not 100% sure where the problem lies as no url to an example is given. I wonder if the problem is on our 'Place' template (I created 3 major templates: People, Places and Things) here:
https://cy.wikipedia.org/wiki/Nodyn:Pethau
I'm away with family until the end of next week, and you're most welcome to find-replace with a better code!
Diolch yn fawr / Many thanks.

Mentioned in SAL (#wikimedia-operations) [2026-06-15T02:17:58Z] <Amir1> making Dexbot a bot in cywiki (T428927)

I hope you have a nice time!

I started the script. Here is the contributions to follow: https://cy.wikipedia.org/wiki/Arbennig:Contributions/Dexbot let me know if it's not correct.

cywiki has been cleaned up. Only 47 cases left.

Ladsgroup claimed this task.

done now