Page MenuHomePhabricator

Don’t suggest edits to real items in API sandbox
Open, Needs TriagePublic

Description

As a developer experimenting with the Wikidata API, I don’t want real, non-sandbox items to be edited when testing the examples in the API Sandbox.

Problem:
The examples for several Wikibase API modules – wbeditentity, wbcreateclaim, wbsetlabel, etc. – use Douglas Adams (Q42) as an example item. They should default to a safer item instead, such as the Wikidata Sandbox (Q4115189).

Example:
This edit was made via the API examples (source).

Acceptance criteria:

  • The examples for API modules that edit items (git grep needsToken repo/includes/Api/) use some sandbox item as the example item.

Open questions:

  • I’m assuming that this will result in some new configuration variable, $wgWBRepoSettings['exampleEntityId'] or whatever, that’s used in the various getExamplesMessages() methods. However, the text of the example is an interface message which currently references the Q42 ID directly. Can we somehow inject the real entity ID into the messages, or do we need to rephrase them to say something vague like “edit an example item”?
  • Assuming the ID is configurable, what’s the default for other Wikibase installations? Still Q42? Q1? Q999999999?
  • Some API modules also use property IDs – some of them don’t exist (P1, P2), some do (P212), some don’t yet but eventually will (P9001 to P9004). Do we want to do anything about those or is that a separate issue?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 25 2019, 7:10 PM

Can we somehow inject the real entity ID into the messages, or do we need to rephrase them to say something vague like “edit an example item”?

Sounds like that’s possible, yes: the return value of getExamplesMessages() “has query strings as keys, with values being either strings (message key), arrays (message key + parameter), or Message objects.” So far we’ve just used plain message keys, but we can also switch it to something like [ 'apihelp-wbeditentity-example-1', $exampleEntityId ] or this->msg( 'apihelp-wbeditentity-example-1' )->plaintextParams( $exampleEntityId ).