Page MenuHomePhabricator

Wikidata should fire "wikipage.content" when an edit is published
Open, LowPublic

Description

When a user edits some data on a Wikidata item, the page is not reloaded, but its content changes to reflect the new values. Therefore, the script which makes this edit should fire the hook "wikipage.content"¹ so that gadgets which use the content can be notified about this. In particular, I would like
https://www.mediawiki.org/wiki/Snippets/Last_revision_action
to work on Wikidata.

As an example, the live preview feature from MediaWiki itself fires this hook:
https://github.com/wikimedia/mediawiki/blob/558b28003fc234f9c7ab3dfd83c8364f4e7260bc/resources/src/mediawiki/page/startup.js#L31

¹ https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.hook-event-wikipage_content

Event Timeline

Wikibase fires mw.hook( 'wikibase.statement.saved' ).

I have been looking for something like this too. wikibase.statement.saved works for statements, but there can also be edits to the terms (i.e. labels, descriptions, aliases), sitelinks, lemmas, forms and senses and I'm not aware of any hooks that cover those.

Addshore triaged this task as Medium priority.Nov 6 2018, 11:36 AM
Addshore moved this task from Incoming to Ready to estimate on the Wikidata-Campsite board.

Note that wikipage_content is defined as "Fired when wiki content is added to the page". It's parameter is all the rendered content. Wikibase however includes both ui and content at the page level, so it might not be a direct fit.

So, this moved back to "needs work" due to T186356#4724465
wikipage.content might not make sense,

We do have wikibase.statement.saved and wikibase.statement.removed

I don't think there are any more appropriate hooks within mediawiki?
So we would likely need to add some of our own, the question is what.

I'll ping some people to gather some thoughts.

For the thing I'm trying to do, I'm interested in knowing when labels, lemmas, forms and senses have been saved or when the editing of them has been cancelled (since it re-renders them when leaving the edit interface). A single generic hook would work for me, so would multiple more specific hooks.

So would wikibase.edit.start and wikibase.edit.cancel for example be enough?

That sounds like it would work for me

That sounds like it would work for me

I guess this should be filed as a seperate ticket rather than hijacking this one

Addshore lowered the priority of this task from Medium to Low.Feb 27 2019, 10:58 AM