Page MenuHomePhabricator

Board.topics does not respect limit argument
Closed, ResolvedPublic

Description

As first encountered on T138215, Board.topics does not respect the limit argument.

from pywikibot.flow import Board
site = pywikibot.Site('test', 'test')
board = Board(site, 'Talk:Sandbox')
topics_list = board.topics(limit=2)
for topic in topics_list:
    print(topic)

returns an unlimited list, except that it fails midway with T105859: Some Flow topics are not being created properly in core page and revision tables:

[[test:Topic:T63mvwp0c7chy9c3]]
[[test:Topic:T5y39gw54bnw2ice]]
[[test:Topic:T40a7hu3rdj1w3kv]]
[[test:Topic:T2d0esp9nk0tvt2z]]
[[test:Topic:T2d0bc2kfgj5z7d2]]
...

Event Timeline

The method is a generator. The limit parameter simply gets passed to the API as a per-query limit. It has no effect on how many topics the generator will eventually return. It's more of a design issue than a usual bug.

Xqt subscribed.

Unable to repoduce due to this API Error:

WARNING: API error invalid-page: Page provided does not have Structured Discussions enabled and safeAllowCreation failed with: * Page already exists at destination, so a Structured Discussions board can not be moved there. * User does not have the "Create Structured Discussions boards in any location" permission
Traceback (most recent call last):
  File "<pyshell#22>", line 1, in <module>
    for topic in topics_list:
  File "C:\pwb\GIT\core\pywikibot\flow.py", line 127, in topics
    data = self.site.load_topiclist(self, content_format=content_format,
  File "C:\pwb\GIT\core\pywikibot\site\_decorators.py", line 60, in callee
    return fn(self, *args, **kwargs)
  File "C:\pwb\GIT\core\pywikibot\site\_extensions.py", line 419, in load_topiclist
    data = req.submit()
  File "C:\pwb\GIT\core\pywikibot\data\api.py", line 1922, in submit
    raise pywikibot.exceptions.APIError(**result['error'])
pywikibot.exceptions.APIError: invalid-page: Page provided does not have Structured Discussions enabled and safeAllowCreation failed with: * Page already exists at destination, so a Structured Discussions board can not be moved there. * User does not have the "Create Structured Discussions boards in any location" permission
[help: See https://test.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes.]

It appears the sandbox has been converted back to a regular wikitext page since this issue was posted. https://test.wikipedia.org/wiki/Talk:Pywikibot_test is the designated Flow test page on that wiki for PWB. You could try testing there.

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

[pywikibot/core@master] [bugfix] Respect limit argument with Board.topics()

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

Change 805828 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Respect limit argument with Board.topics()

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

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

[pywikibot/core@master] [bugfix] Respect limit argument with Board.topics()

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

Change 808420 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] Respect limit argument with Board.topics()

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