Page MenuHomePhabricator

Improve integration between Wikidata and MDWiki
Open, MediumPublic

Description

MDWiki currently uses UnlinkedWikibase.

The goal is to have Wikidata work on MDWiki the same way it works on Wikipedia, including links to articles in other languages. (T355725)

Module:WDfetch bridges the gap and provides data for articles. It would be nice if we could just use Wikipedia's templates.

Module:WikidataIB is an example of a module that is broken.

Event Timeline

Harej added a subscriber: Doc_James.

Do we invest more effort into UnlinkedWikibase or look somewhere else?

@Samwalton9 How is the state of UnlinkedWikibase these days? If our goal is to support Wikipedia Lua modules that use Wikidata, and to enable the language dropdown, how much work would it take?

@Lydia_Pintscher Are there better alternatives at this point?

@Samwalton9 How is the state of UnlinkedWikibase these days? If our goal is to support Wikipedia Lua modules that use Wikidata, and to enable the language dropdown, how much work would it take?

I don't know anything about this extension - I suspect you're after @Samwilson :)

Harej triaged this task as Medium priority.Jan 29 2024, 10:47 PM

@Lydia_Pintscher Are there better alternatives at this point?

I am not aware of any, no.

How is the state of UnlinkedWikibase these days? If our goal is to support Wikipedia Lua modules that use Wikidata, and to enable the language dropdown, how much work would it take?

Finishing support for {{#statements}} (mostly done) and {{#property}} (not started) isn't a huge amount of work (tracked in T344487), but the main issue is of how to pass the Wikidata ID in. Currently {{#statements}}, in addition to having the |from= parameter, will use a page's defined Wikibase ID as defined anywhere in the page with {{#unlinkedwikibase: id=Qnnn }}. This breaks if it's used before it's defined, and will break with Parsoid rendered wikitext, so isn't great. The best fix probably is for templates to pass in the Wikidata ID they want to use, but if your goal is to be able to use Wikipedia templates without modifying them then that's probably not how they're designed.

The main actual outstanding work for UnlinkedWikibase at the moment is to make it work better when a page uses lots of Wikibase entities; that's tracked in T337655. The issue is that the remote fetching is currently done during parse and so it's slow. Often, wikis don't need up-to-the-minute data and so an out of band fetch/update makes for a much better editing experience.

Every page that exists on MDWiki has been tagged to the Wikidata item using the WikiProjectMed ID

https://www.wikidata.org/wiki/Property:P11143

Could we use this?

Currently we have added the #unlinkedwikibase template to the top of all articles.

If every page already contains its Wikidata ID then there's no need to use WikiProjectMed ID, but yeah it could well work if you didn't want to do that. It's less efficient though because for each page it'd have to do a query to find the Wikidata ID. For example, to get the Wikidata ID of the mdwiki Malaria article, you could do something like the following:

Module:Wikidata
local p
p.getWikidataIdForMdWiki = function ( frame )
	local title = nil
	if frame.args and frame.args.title then
		title = frame.args.title
	else
		title = mw.getCurrentFrame():getTitle()
	end
	local sparql = 'SELECT ?item WHERE { ?item wdt:P11143 "' .. title .. '"}'
	local results = mw.ext.UnlinkedWikibase.query( sparql )
	if results.results ~= nil then
		local wdId = string.sub( results.results.bindings[0].item.value, string.len( 'http://www.wikidata.org/entity/' ) + 1 )
		return wdId
	end
end
return p

Test it with e.g. =p.getWikidataIdForMdWiki( { args = { title = 'Malaria' } } )

But yeah, it's probably easier to use {{#unlinkedwikibase:id=Q12156}} (although I'd recommend wrapping that in a template so it can more easily be changed across all articles if need be).