Page MenuHomePhabricator

Modify the regex that evaluates the SortedProperties page
Open, Needs TriagePublic

Description

Preamble

As explained in the manual page for Interface/Wikibase-SortedProperties, the order of properties in a Wikibase item is determined by parsing the MediaWiki:Wikibase-SortedProperties page (live example on Wikidata).

Note that the page is just something like this:

* P7
* [[Property:P8]]

And the properties are actually parsed using this regular expression:

^[*#]+\h*(?:\[\[(?:d:)?Property:)?(P\d+\b)

That matches rows with the plain property name or starting with a link.

Problem

As you can see the list of properties (live example on Wikidata) it is quite spartan and difficult to navigate / verify.

Proposed solution

I propose to modify the regex so it can match templates as well:

* P7
* [[Property:P8]]
* {{NiceTemplate|P8}}

This would allow the creation of a standard template to present the properties in a more readable and / or more detailed way to the user, still preserving the functionality of the page.
The proposed regex is:

^[*#]+\h*(?:\[\[(?:d:)?Property:)?(?:{{.*|)?(P\d+\b)

You can test this regex with your favorite regex debugger over the live example on Wikidata.

Event Timeline

Change 681375 had a related patch set uploaded (by Luca Mauri; author: Luca Mauri):

[mediawiki/extensions/Wikibase@master] Modify the regex that evaluates the SortedProperties page to allow use of templates

https://gerrit.wikimedia.org/r/681375

As per @Michael suggestion, I have modified the new regex for a stricter match, so it now looks like:

^[*#]+\h*(?:\[\[(?:d:)?Property:)?(?:{{[a-zA-Z]+\|)?(P\d+\b)

Just wanted to note that using a template for all the properties on the page surely wont work (these are just to many), but IMO this is probably still useful for highlighting specific properties and for wikis which have fewer entries then Wikidata.

Change 681375 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Modify the regex that evaluates the SortedProperties page to allow use of templates

https://gerrit.wikimedia.org/r/681375

Just wanted to note that using a template for all the properties on the page surely wont work (these are just to many),

Thanks for pointing that out, we might add this to the manual page to inform the user.

but IMO this is probably still useful for highlighting specific properties and for wikis which have fewer entries then Wikidata.

Actually this is the reason I came up with this modification proposal in first place: I devised it for my own Wikibase instance where I have around 100 properties. So I thought about sharing for other users with similarly small custom Wikibase.

@Lydia_Pintscher we don't have ACs for this one, but we should probably update the docs too?