Page MenuHomePhabricator

category move bug when "from" = "to"
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Let's move the category pages to a category with an identical name: pwb.py category -site:wikisource:ru move -from:"Фёдор Павлович Аделунг" -to:"Фёдор Павлович Аделунг" -inplace

What happens?:
Pages are drop from this category. example1, example1. This bug was discovered during batch processing of a lot of subcategories.

What should have happened instead?:
If the original and target categories are identical, the pages should remain in the category "-to:", the edits should be skipped. Because to remove pages from categories the following options are used: -from:"original category" -to:"".

Event Timeline

Xqt triaged this task as High priority.Jan 25 2025, 11:44 AM
Xqt added a project: Pywikibot-category.py.

I think the bug is somewhere in category.py _change()/pywikibot/page/_basepage.pychange_category() subfunction. Maybe on line #2255. Or in pywikibot/textlib.pytextlib.replaceCategoryInPlace() subfunction on line #1576.
Somewhere there should be a check: if oldcat == newcat: skip.

Xqt changed the task status from Open to In Progress.Feb 25 2025, 6:07 AM
Xqt claimed this task.

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

[pywikibot/core@master] [bugfix] ensure that -from and -to arguments are not equal

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

Change #1122287 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] ensure that -from and -to arguments are not equal

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