Page MenuHomePhabricator

Don’t suggest edits to real items in API sandbox
Closed, ResolvedPublic5 Estimated Story Points

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 example Item, by default Q999999999.
  • Examples on Wikidata use Q4115189 as an example Item.
  • Documentation incl. release notes is adjusted for 3rd-party Wikibase installs to say that this new config option exists.

Previous deliberation, left for the curious reader

Open questions:

  • I’m assuming that this will result in some new configuration variable, $wgWBRepoSettings['sandboxEntityId'] 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”?
    • Answer: Lucas says we can inject the ID into the message.
  • Assuming the ID is configurable, what’s the default for other Wikibase installations? Still Q42? Q1? Q999999999?
    • Answer: Let's go with 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?
    • Answer: Let's leave it for now.

Event Timeline

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 ).

Note from Story Time: The default value for 3rd party Wikibases should remain Q42

So we’re going to let third-party Wikibases shoot themselves in the foot by default? And on an item that doesn’t even have special significance outside of Wikidata (but, due to its low ID, is still likely to exist)?

It was decided to leave the default as it is now and let the PM - Sam - decide whether this id should be changed for 3rd party Wikibases

Although some examples include a hardcoded Q2 rather than Q42... @Addshore what should we do about those? Is it fine for them to change from Q2 to Q42 in 3rd party Wikibases?

Although some examples include a hardcoded Q2 rather than Q42... @Addshore what should we do about those? Is it fine for them to change from Q2 to Q42 in 3rd party Wikibases?

My gut would say that keeping something nice and small for those such as Q42 would be fine (even if this is a change from the default).
Technically this would be a decision for @Samantha_Alipio_WMDE , but I have a feeling she would be fine with Q42 here

Although some examples include a hardcoded Q2 rather than Q42... @Addshore what should we do about those? Is it fine for them to change from Q2 to Q42 in 3rd party Wikibases?

My gut would say that keeping something nice and small for those such as Q42 would be fine (even if this is a change from the default).
Technically this would be a decision for @Samantha_Alipio_WMDE , but I have a feeling she would be fine with Q42 here

I am curious why we wouldn't also want to use a high, unlikely-to-exist QID for 3rd party Wikibases such as Q999999999. Absent some compelling argument, I am with Lucas on this one and would prefer to see us not use a low QID (e.g. Q42).

Sure, I was just bringing the discussion from yesterday's story time over to here.

I am curious why we wouldn't also want to use a high, unlikely-to-exist QID for 3rd party Wikibases such as Q999999999. Absent some compelling argument, I am with Lucas on this one and would prefer to see us not use a low QID (e.g. Q42).

The only reason I could think of would be that it's quite a long thing to look at.

Change 698513 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):

[mediawiki/extensions/Wikibase@master] Add sandboxEntityId configuration

https://gerrit.wikimedia.org/r/698513

Change 698514 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):

[mediawiki/extensions/Wikibase@master] Replace hardcoded example entity ids with sandbox entity ids.

https://gerrit.wikimedia.org/r/698514

Change 698518 had a related patch set uploaded (by Itamar Givon; author: Itamar Givon):

[operations/mediawiki-config@master] Set Wikidata's main sandbox item

https://gerrit.wikimedia.org/r/698518

Change 698513 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Add sandboxEntityIds configuration

https://gerrit.wikimedia.org/r/698513

Change 698514 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Replace hardcoded example entity ids with sandbox entity ids.

https://gerrit.wikimedia.org/r/698514

Stalled until ca. 2021-06-24, when we can deploy the corresponding config change.

Addshore added a subscriber: ItamarWMDE.

Looks like this could be done now then.
Also removing @ItamarWMDE as he is no longer on camp!

Ladsgroup subscribed.

@Addshore It's not 24 yet. wmf.11 is stalled given that it's allhands and no train this week.

Change 698518 merged by jenkins-bot:

[operations/mediawiki-config@master] Set Wikidata's main sandbox item

https://gerrit.wikimedia.org/r/698518

(I had already scheduled it for deployment later today…)

Mentioned in SAL (#wikimedia-operations) [2021-06-28T08:19:41Z] <ladsgroup@deploy1002> Synchronized wmf-config/InitialiseSettings.php: Config: [[gerrit:698518|Set Wikidata's main sandbox item (T219215)]], Part I (duration: 00m 57s)

Mentioned in SAL (#wikimedia-operations) [2021-06-28T08:21:36Z] <ladsgroup@deploy1002> Synchronized wmf-config/Wikibase.php: Config: [[gerrit:698518|Set Wikidata's main sandbox item (T219215)]], Part II (duration: 00m 56s)

(I had already scheduled it for deployment later today…)

And? It's assigned to me, I already said I would do it Monday.

Okay, but you assigned it to yourself after I had already scheduled it… I guess next time I’ll update Phabricator as well.

I didn't check them all but LGTM!

image.png (657×2 px, 262 KB)