A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

Wikidata: How to update revision after doing change

MichaelSchoenitzer

Hi,

I wrote a gadget editing Wikidata. I managed to find out how to add new statements to an item:

Code
	guid= (new wb.utilities.ClaimGuidGenerator(qid)).newGuid();
	cl = new wb.datamodel.Claim(snak, null, guid);
	st = new wb.datamodel.Statement(cl);
	g = new wb.datamodel.StatementGroup(prop);
	g.addItem(st);

	entity = new wikibase.datamodel.Item(qid);
    deserializer = new wb.serialization.StatementDeserializer();
	revisionStore = new wb.RevisionStore( mw.config.get( 'wgCurRevisionId' ) );
	entityChangersFactory = new wb.entityChangers.EntityChangersFactory(
		new wb.api.RepoApi(new mw.Api()),
		revisionStore,
		entity
	);
	sc = entityChangersFactory.getStatementsChanger();
	sc.save(st).done( function ( result ) { /* … */ });

But what I haven’t figured out is how do I update the revisionStore, so that the newly added statement is editable. I’m kinda stuck here, so would appreciate any help.

And yes, I know that the Wikidata-Javascript-API is not stable yet and that such gadget might break in future – but I anyway don’t want to wait anymore. :stuck_out_tongue_winking_eye:

LucasWerkmeisterWMDE

I think the DuplicateReferences gadget has the same problem (I tried to investigate that almost a year ago) – it has its own RevisionStore that it updates, but I couldn’t figure out how it could use the main UI’s RevisionStore, which doesn’t seem to be accessible anywhere.

Sorry that this isn’t a great answer – but if you find a solution, perhaps you can fix that gadget as well? :slight_smile:

MichaelSchoenitzer

So, I basically gave up. My JS-Knowlege is to bad to figure this out and I already spent to much time trying to “bruteforce” this. I’ve subscribed to the other ticket to see if there is any news there.