Some templates on Commons like for example https://commons.wikimedia.org/wiki/Creator:Jan_Ekels_%28II%29 link to Wikidata items. I merged the item this template is pointing to. I'm looking for a Lua function to check if a certain item (in this case "Q18516596") is a redirect and what the target item is (in this case "Q2450553"). Maybe this is already possible, but couldn't find it anywhere in the documentation.
Description
Related Objects
Event Timeline
In theory it shouldn't matter which ID you access an item with. Can you elaborate what you need to know it for?
To find creator templates that point to a redirect so we can keep the data consistent.
Workaround: mw.wikibase.getEntity() always returns the target entity with the new id. So you can do:
local id = ... local entity = mw.wikibase.getEntity(id) if id ~= entity.id then it's redirected end
I verified that the solution proposed at T68974 for regular redirects also works with redirect items (and there's no reason it shouldn't)
Oddly enough, the id of that task is an anagram of this one's. I'd like to know how many times such a thing has happened.
Matej, workaround seems to solve the problem. Maybe we should document the way to check for redirects and close this task, or do we want to add short trivial function to mw.wikibase to do the test?
Opps the task is already closed after code change. If there is such a function than it should be documented at https://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua