Page MenuHomePhabricator

Do not regress template counter values
Open, MediumPublicBUG REPORT

Description

archivebot should not regress counter values even if the previous archive is not yet full.

In en.wikiquote they decided to finish their archive 61 and start a new archive 62 for the threads starting January 2023.

The bot however insists on trying to use Archive 61, probably because that page has not yet reached the maxarchivesize set in the configuration template:

Running archivebot module for enwikiquote at Sat 11 Mar 2023 09:52:08 PM UTC.
Fetching template transclusions...
 ***

>>> [[en:Wikiquote:Village pump]] <<< ***
22 thread(s) found on [[en:Wikiquote:Village pump]]
Looking for: {{User:MABot/config}} in [[en:Wikiquote:Village pump]]
Processing 22 threads
56 thread(s) found on [[en:Wikiquote:Village pump archive 61]] <-- note that User:MABot/config has 62
Archiving 15 thread(s).
Sleeping for 7.1 seconds, 2023-03-11 21:52:13
WARNING: API error protectedpage: This page has been protected to prevent editing or other actions.
ERROR: Error occurred while processing page [[en:Wikiquote:Village pump]]
Traceback (most recent call last):
  File "/pywikibot-core/scripts/archivebot.py", line 831, in process_page
    archiver.run()
  File "/pywikibot-core/scripts/archivebot.py", line 784, in run
    archive.update(comment, sort_threads=self.sort)
  File "/pywikibot-core/scripts/archivebot.py", line 466, in update
    self.save(summary)
  File "/pywikibot-core/pywikibot/page/_basepage.py", line 1276, in save
    self._save(summary=summary, watch=watch, minor=minor, botflag=botflag,
  File "/pywikibot-core/pywikibot/page/_decorators.py", line 55, in wrapper
    handle(func, self, *args, **kwargs)
  File "/pywikibot-core/pywikibot/page/_decorators.py", line 46, in handle
    raise err
  File "/pywikibot-core/pywikibot/page/_decorators.py", line 34, in handle
    func(self, *args, **kwargs)
  File "/pywikibot-core/pywikibot/page/_basepage.py", line 1288, in _save
    done = self.site.editpage(self, summary=summary, minor=minor,
  File "/pywikibot-core/pywikibot/site/_decorators.py", line 92, in callee
    return fn(self, *args, **kwargs)
  File "/pywikibot-core/pywikibot/site/_apisite.py", line 1973, in editpage
    raise exception(page) from None
pywikibot.exceptions.LockedPageError: Page [[en:Wikiquote:Village pump archive 61]] is locked. ***

I do not think the bot should be substracting archive counter values (e.g. from 62 to 61). Increasing the number is totally fine.

I'm using Pywikibot stable 8.0.1 via git on Toolforge.

Thank you.

Event Timeline

The reason for the regression is T215247. Imagine you have the archive partitioned by the year (month, etc.) and the counter. Then, by the year's end, the counter could have increased up to 5. When the year ticks, the counter stays at 5, but you want to start from 1. We solve this by having the bot check for archive existence and decrement the counter in a loop until it finds an existing archive.

A simple workaround is to update the counter AND create the new archive manually before the archive bot runs again.

Maybe the above algorithm can be improved. For example, when the archive does not exist, we can have it check just the archive for counter = 1. If it doesn't exist, it is clear there was a "tick", and the bot can continue from there. If it does, do nothing with the counter and continue as usual.

Thank you for your help @matej_suchanek - I'll do as indicated and see if the bot wants to archive their VP afterwards :-)

Xqt triaged this task as Medium priority.Apr 3 2023, 1:29 PM