Page MenuHomePhabricator

Incorrect normalization of pywikibot.WbTime
Closed, ResolvedPublicBUG REPORT

Description

I noticed my bot doing weird edits like https://www.wikidata.org/w/index.php?title=Q2270291&diff=prev&oldid=1924431056 . Here the bot should have changed it to 1598, but for some reason it change it to 2000. This is incorrect behavior. This normalization shouldn't happen. Found the problem at https://github.com/wikimedia/pywikibot/blob/master/pywikibot/page/_wikibase.py#L1982 . normalize shouldn't be true.

Bug seems to be introduced in T325860 / https://gerrit.wikimedia.org/r/c/pywikibot/core/+/872504/

Event Timeline

I mean it partially isn’t a bug as the precision is set to millennium. If you want a more specific date value then the precision should be updated to be more precise. 2000 and 1500 are in the same millennium, the 2nd millennium.

Xqt triaged this task as High priority.Jun 27 2023, 2:06 AM

This is a bug. This causes bots to butcher up dates. Say for example a painting is sourced to be made between 1190 and 1210. The year will be set to 1200 with a precision of a millennium with earliest date 1190 and latest date 1210. The 1200 is used for sorting and other cases where things are just grouped together. This would be changed to 2000 with the current logic. This is not in line with https://www.wikidata.org/wiki/Help:Dates .

Change 934692 had a related patch set uploaded (by Multichill; author: Multichill):

[pywikibot/core@master] Remove incorrect time normalization

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

Xqt claimed this task.

Change 934692 merged by jenkins-bot:

[pywikibot/core@master] Remove incorrect time normalization

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

Change 934708 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] Revert "[Bugfix] Normalize WbTimes sent to Wikidata"

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

I agree with Multichill, therefore I submitted his patch. The underlying problem of T325860 is described in T57755: it is currently not possible to enter time values more precise than 1 day on wikidata.org

Change 934708 merged by jenkins-bot:

[pywikibot/core@master] Revert "[Bugfix] Normalize WbTimes sent to Wikidata"

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