Page MenuHomePhabricator

Wikibase automated edit summary is showing double the number of references changed
Open, HighPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:
Although there is one reference is changes it is logged as "Changed 2 references of claim:"

image.png (791×48 px, 20 KB)

What should have happened instead?:
It should say "Changed reference of claim"


Original ticket

When my bot updates a single reference on Wikidata the text "Changed 2 references of claim" is automatically preprended to the edit summary.

e.g. this diff https://www.wikidata.org/w/index.php?diff=prev&oldid=2443602387
or https://www.wikidata.org/w/index.php?diff=prev&oldid=2443521057

On 17 December 2025 it was just prepending "Updated Item:"

e.g. https://www.wikidata.org/w/index.php?diff=prev&oldid=2443432605

Bot code is at https://bitbucket.org/WilliamAvery/wikipythonics/src/master/cleanseRefs.py

Event Timeline

William_Avery renamed this task from Wikibse automated edit summary is showing double the number of references changed to Wikibase automated edit summary is showing double the number of references changed.Dec 26 2025, 5:54 PM
Lydia_Pintscher subscribed.

Wrong edit summaries are not good. Marking prio high.
Omega team: Please have a look.

This was already a known issue when the improved edit summaries were introduced (albeit for qualifiers instead of references), see the commit message or T410130#11383715: as far as Wikibase is concerned there really are two changes here, one removal (old reference) and one addition (new reference). That’s also how the diff is being presented visually (notice that it has two rows and no “in-value diff”, compared to e.g. a description change).

It’s not clear to me how we could improve this; qualifiers and references don’t have stable/persistent identifiers of their own, so we can’t with certainty distinguish between a qualifier/reference being edited or one being removed and a similar one being reintroduced. This is especially true in the case in the edit summary task description where the reference doesn’t have any snaks that didn’t change (no retrieved date or similar). I think our only option is effectively a heuristic in the differ, with some kind of edit distance threshold for changes to consider edits rather than removals+additions.

or https://www.wikidata.org/w/index.php?diff=prev&oldid=2443521057

That link doesn’t work for me. “One revision of this difference (2443521057) was not found.”

(Or we could make the edit summaries a bit less detailed again and just reduce it to “changed claim”, the same as you’d get from the wbsetclaim API.)

Thanks!

That technically makes sense but not really for the user I fear :/

To better understand:

so we can’t with certainty distinguish between a qualifier/reference being edited or one being removed and a similar one being reintroduced

If it's in the same edit I am not sure I understand what the difference would be. Isn't removing one and adding one effectively the same as changing one? Or is it not possible to know if it's on the same statement?

Thanks!

That technically makes sense but not really for the user I fear :/

To better understand:

so we can’t with certainty distinguish between a qualifier/reference being edited or one being removed and a similar one being reintroduced

If it's in the same edit I am not sure I understand what the difference would be. Isn't removing one and adding one effectively the same as changing one?

Is it? Did this edit change the reference, or completely replace it with a new one?

(In the UI I made this edit by changing all the snak values, but I think the backend would’ve seen the same data if I’d removed the old reference and then added a new reference with the same properties in the same order before clicking ”publish”.)

Right. But effectively does it make a difference if I add one and remove one or change one? The end result is the same if I do it in one edit I'd say.

Okay, so what number do we put in the edit summary? max(n_add, n_remove) instead of n_add + n_remove?

(We could also try to modify the diffing code itself so it’ll emit some DiffOpChange objects in addition to DiffOpAdd + DiffOpRemove, but I would be much more careful there because that would also affect how edit conflict resolution happens. If we can find a satisfactory solution that only changes the number that goes into the edit summary, that sounds safer to me.)

And does the same apply to qualifiers as well? If you remove one qualifier and add another qualifier (perhaps even with a different property ID), should we also count that as one?

Change #1226912 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] Modernize ClaimSummaryBuilder and clean up tests

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

Change #1226913 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] WIP: Improve edit summaries for editing qualifiers and references

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

(The above change implements the “max(n_add, n_remove)” rule, for both qualifiers and references, but we still need to know from Product if that’s correct or not ^^ so I think the task should still stay in the Ready for Story Writing column.)

Okay, so what number do we put in the edit summary? max(n_add, n_remove) instead of n_add + n_remove?

To answer this I've been playing around with this a bit and it seems I'm always getting the generic edit summary. Example: https://www.wikidata.org/w/index.php?title=Q4115189&diff=prev&oldid=2455453193 🤔

Yes, if you use the UI then you’ll always get the more generic edit summary. (The number is actually still there in the summary – you can see it in the API – but not shown in the formatted message.) The more specific edit summary is only used when the edit is made via wbeditentity. (wbsetclaim only used the more specific edit summary between 2013 and 2014, see T410130#11374023 and T410130#11383715.)

Ahhhhhhh! Thx. I missed that crucial part.
I have the sneaking suspicion that I'm still missing something because I hadn't thought of it as max(n_add, n_remove) like you. And it made me think of references versus their snaks. What does the edit summary actually count? 🤔
Example: I am making an edit that adds one new reference snak and changes one existing reference snak. Then in my mind all in all I have changed one reference and I have changed one reference snak and added on reference snak.

Probably needs sitting down together and untangling it at some point.

I think this code doesn’t look at the individual reference snaks at all. If the reference has changed in any way then it gets diffed as one full removal of the old reference + addition of the new reference.

Yes, if you use the UI then you’ll always get the more generic edit summary.

Self-correction: you can get the more specific edit summary using the new mobile editing experience :) you just have to make sure that there are no unsupported datatypes anywhere in the statement group you’re editing, otherwise you won’t be able to publish the edit. Example edit.

Do you think a good soloution here would be making it more specific: "one reference deleted and one reference created"

Change #1226912 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Modernize ClaimSummaryBuilder and clean up tests

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

Do you think a good soloution here would be making it more specific: "one reference deleted and one reference created"

That’s technically possible, but I’m not sure it’s better… wouldn’t people still think that’s misrepresenting the edit?

karapayneWMDE subscribed.

could we please get clear guidelines for the language to be used?