Page MenuHomePhabricator

IndexPage cannot be save if page has categories
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

import pywikibot
from pywikibot import proofreadpage as pp
site = pywikibot.Site('en', 'wikisource')
page = pp.IndexPage(site, 'Index:Pywikibot_test_page_2')
page.save(summary='test edit')

What happens?:

~/python/core/pywikibot/proofreadpage.py in save(self, *args, **kwargs)
    858         """
    859         if not self.has_valid_content():
--> 860             raise OtherPageSaveError(
    861                 self, 'An IndexPage must consist only of a single call to '
    862                 '{{%s}}.' % self.INDEX_TEMPLATE)

OtherPageSaveError: Edit to page [[Index:Pywikibot test page 2]] failed:
An IndexPage must consist only of a single call to {{:MediaWiki:Proofreadpage_index_template}}.

What should have happened instead?:
Page is saved without errors.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

Pywikibot: [ssh] pywikibot-core.git (48e05cf, g15783, 2022/01/09, 12:47:08, OUTDATED)
Release version: 7.0.0.dev0
setuptools version: 58.0.4
mwparserfromhell version: 0.6.2
wikitextparser version: n/a
requests version: 2.27.1
Python: 3.8.3 (default, Jul  2 2020, 16:21:59) 
[GCC 7.3.0]

Event Timeline

page.text is:

'{{:MediaWiki:Proofreadpage_index_template\n|Type=book\n|Title=\n|Language=en\n|Volume=\n|Author=\n|Translator=\n|Editor=\n|Illustrator=\n|School=\n|Publisher=\n|Address=\n|Year=\n|Key=\n|ISBN=\n|OCLC=\n|LCCN=\n|BNF_ARK=\n|ARC=\n|DOI=\n|Source=_empty_\n|Image=Albert-Auguste Cochon de Lapparent.jpg\n|Progress=C\n|Transclusion=no\n|Validation_date=\n|Pages=[[Page:Pywikibot test page.djvu/1]]\n|Volumes={{Notice|This page is used for continuous integration of pywikibot library.\n\nDo not delete without contacting Pywikibot team (or [[User:Mpaa]] on this site).}}\n|Remarks=\n|Width=\n|Css=\n|Header=\n|Footer=\n}}\n[[Category:Test]]\n[[Category:Test cat]]'

The trailing categories are currently not accepted as part of valid text when validating content.

Change 756061 had a related patch set uploaded (by Mpaa; author: Mpaa):

[pywikibot/core@master] [bugfix] Allow categories when saving IndexPage

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

Change 756061 merged by Xqt:

[pywikibot/core@master] [bugfix] Allow categories when saving IndexPage

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