Hello all,
We recently made some changes to the way the Wikidata Query Service UI ( https://query.wikidata.org/) loads the example queries https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples. This change can impact people who are maintaining these queries, as well as people running their own Wikibase instance including the Query Service.
Before the change, our approach was to get the HTML of that wiki page from Parsoid https://www.mediawiki.org/wiki/Parsoid (this includes some template metadata which the normal parser output doesn’t include), and from that extract the query parameters of all {{SPARQL}} and {{SPARQL2}} transclusions.
With our improved approach, we get the HTML of that wiki page from the parser https://www.mediawiki.org/wiki/API:Parsing_wikitext, and from that extract the contents of all syntax highlighted blocks.
The improvements resulting from this change are the following:
-
The queries no longer have to be specified directly on the page using {{SPARQL}} or {{SPARQL2}}; they can be transcluded indirectly, e. g. using {{query page}} https://www.wikidata.org/wiki/Template:Query_page#Transclusion_usage. You can see a comparison at User:TweetsFactsAndQueries/Queries-test-transclude https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/Queries-test-transclude and User:TweetsFactsAndQueries/Queries-test-copy https://www.wikidata.org/wiki/User:TweetsFactsAndQueries/Queries-test-copy. If we go with the solution of one query per page, we should be aware that we can fit less queries on the examples page before we hit some parser limits. -
Examples can be loaded from wikis that don’t have Parsoid / VisualEditor installed, making it much easier for third-party setups to manage their own lists of examples.
-
Queries that contained an unescaped pipe character (|) were previously cut off at that character in the query service UI, this should now be fixed and all queries should be displayed just like on the wikipage. -
If the examples page hits some limit of the parser, then some examples will not be loaded, whereas with the previous approach they would still be loaded and shown on the query service UI even though they weren’t working correctly on the wiki page.
Configuration changes for other Wikibase instances: third-party setups may have to update their configuration (custom-config.json). In the 'examples' object, the 'endpoint' (pointing to the REST API for Parsoid) has been replaced with the 'apiPath' (the path to api.php after the 'server'; related to $wgScriptPath https://www.mediawiki.org/wiki/Manual:$wgScriptPath, but without a leading slash [should instead be at the end of the 'server'] and including the /api.php at the end).
If you encounter any issues with the examples page or while configuring your own Query Service instance, please let us know by adding a comment under this task https://phabricator.wikimedia.org/T174298.
Cheers,