Page MenuHomePhabricator

Improve APISite.watch() and Page.watch()
Closed, ResolvedPublicFeature

Description

Feature summary:
https://www.mediawiki.org/wiki/API:Watch says that expiry of a watchlist item may be set, and plenty of builtin pagegenerators may be used to edit watchlist. Both should be used by APISite.watch() and expiry should also be used by Page.watch().

Benefits (why should this be implemented?):
A much more flexible watchlist editing possibility. See https://www.mediawiki.org/wiki/Manual:Pywikibot/Cookbook/Working_with_your_watchlist for ideas.

Event Timeline

Xqt triaged this task as Medium priority.Mar 6 2023, 3:19 PM
Xqt raised the priority of this task from Medium to High.Jul 20 2025, 8:55 AM
Xqt added a subscriber: Antimuonium.
Xqt changed the task status from Open to In Progress.Jul 27 2025, 10:15 AM
Xqt claimed this task.

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

[pywikibot/core@master] IMPR: Add `expiry` parameter to Page.watch() and Site.watch()

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

Change #1172853 merged by jenkins-bot:

[pywikibot/core@master] IMPR: Add `expiry` parameter to Page.watch() and Site.watch()

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

Tests fails on most wikis outside wikipedia family:

C:\pwb\GIT\core>py -3.13 -m pwb -site:wikisource:zh -user:Pywikibot-test page_tests -v TestPageUserAction.test_watch
tests: max_retries reduced from 15 to 3
test_watch (__main__.TestPageUserAction.test_watch)
Test Page.watch, with and without unwatch enabled. ... FAIL

======================================================================
FAIL: test_watch (__main__.TestPageUserAction.test_watch)
Test Page.watch, with and without unwatch enabled.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\pwb\GIT\core\tests\page_tests.py", line 1092, in test_watch
    self.assertIn(userpage, userpage.site.watched_pages(**wp_params))
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: User('User:Pywikibot-test') not found in <pywikibot.data.api._generators.PageGenerator object at 0x000001AB0568AE40>

----------------------------------------------------------------------
Ran 1 test in 6.150s

FAILED (failures=1)

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

[pywikibot/core@master] Tests: Fix watch() to return False if page missing and no expiry set

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

Change #1175523 merged by jenkins-bot:

[pywikibot/core@master] Tests: Fix watch() to return False if page missing and no expiry set

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