Page MenuHomePhabricator

Make /entity/ alias work for Commons
Closed, ResolvedPublic


Wikidata has entity URLs in the form of - which is redirected to and ultimately to

It makes sense to have the same setup for Commons - so that Commons URL would redirect to (and of course carry over all suffixes and query strings just like Wikidata does).

Also statement URIs - like or - should be supported, they should redirect to L40053 and M40538870 entity pages respectively.

Related Objects

Event Timeline

Smalyshev triaged this task as Medium priority.May 2 2019, 6:59 AM

(Just to clarify – Special:EntityData works, it’s “only” the /entity/ redirect that’s missing.)

For wikidata this is done in


We should set up a similar set of things for commons I guess.

Change 526757 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[operations/puppet@production] Support /entity/ and other Wikidata URLs for Commons

Mentioned in SAL (#wikimedia-operations) [2019-08-27T19:08:58Z] <gehel> starting deployment of Apache config for lexemes / SDoC - T222321

Smalyshev updated the task description. (Show Details)

I'd be in favor of enabling the minimum needed here and just do the entity resolution here, doing the statement sounds a bit more complex as it may work for wikibase because we will redirect to the entity page which will support statement anchors, for commons we redirect to the File page.
As you can see in the existing rewrite rule the statement id is completely ignored:

RewriteRule ^/entity/statement/([QqPp]\d+).*$ %{ENV:RW_PROTO}://%{SERVER_NAME}/wiki/Special:EntityData/$1 [R=303,L]

The fix could be:

RewriteRule ^/entity/statement/([QqPp]\d+)-(.*)$ %{ENV:RW_PROTO}://%{SERVER_NAME}/wiki/Special:EntityData/$1#$2 [R=303,L]

But I doubt that would work for commons.

Change 547541 had a related patch set uploaded (by DCausse; owner: DCausse):
[operations/puppet@production] Revert "Revert "Add L and M to allowed statement starts""

@Gehel @dcausse what's the plan here? Currently every file on Commons that uses structured data (about 2M I think) has a (broken) link in the sidebar "Concept URI". For example on . It would be really nice to fix this broken link.

In the current state url's like redirect to which gives a bad request. That rewrite patch should probably reverted and a Commons only patch should be made. Do you agree?

Problem is that Special:EntityData does not support displaying the content of non main slot, it seems to just redirect to the File page: which is not particularly useful because these Concept URI links simply link back to the same File page. I guess the question is more how to make Special:EntityData displays the structured MediaInfo data in the browser. JSON/RDF/TTL format are supported for MediaInfo entities but I can't seem to find how to make it visible in html.
@Lucas_Werkmeister_WMDE, @Cparle what do you think Special:EntityData should do when given a MediaInfo entity?

Nothing is broken if we are OK having Special:EntityData/M123 redirecting back to the File page, the only thing that I don't know how to do is to have direct reference to a particular statement (like the statement id anchor on wikibase entity e.g.$8983b0ea-4a9c-0902-c0db-785db33f767c)

Yeah, it the content negotiation is for html, showing the File page is imho the only correct location to link to.

To be able to link to specific sections, you have to give the div an unique id I think. In your example it's div id="Q1$8983b0ea-4a9c-0902-c0db-785db33f767c" class="wikibase-statementview wikibase-statement-Q1$8983b0ea-4a9c-0902-c0db-785db33f767c wb-normal">

In the example on Wikidata we have: <div data-guid='M1916$8DFF061F-559D-45CC-884B-D7253442138A' class='wbmi-item-container'>. I think if you change that to <div id="M1916$8DFF061F-559D-45CC-884B-D7253442138A" data-guid='M1916$8DFF061F-559D-45CC-884B-D7253442138A' class='wbmi-item-container'> that you should be able to link to this.

Side note: Do we have a convention on single and double quotes? I now see a mix of it in the source code. Only the SDoC code part seems to be using single quotes. I would expect only double quotes.

I agree that nothing is broken with Special:EntityData behavior. It would be nice if it was possible to link to a specific statement group or statement, but I think that’s only weakly related to this task, and doesn’t need to block the redirect for /entity/M….

Change 547541 merged by Gehel:
[operations/puppet@production] Revert "Revert "Add L and M to allowed statement starts""

In summary, it seems we need to merge the patch[1] for the /entity/ endpoint, and this should be resolved?


In summary, it seems we need to merge the patch[1] for the /entity/ endpoint, and this should be resolved?


Yes, commit this and maybe do a follow up patch to split up Wikidata (P..., Q..., etc.) and Structured data on Commons (M....)

Mentioned in SAL (#wikimedia-operations) [2020-02-18T09:09:05Z] <gehel> disabling puppet on mw* to deploy apache config change - T222321

Change 526757 merged by Gehel:
[operations/puppet@production] Support /entity/ and other Wikidata URLs for Commons