Page MenuHomePhabricator

Replacement is reapplied when more context is requested
Closed, ResolvedPublicBUG REPORT

Description

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

  • Run pwb.py replace "^" "a" -regex -summary:test on a sandbox page in interactive mode.
  • When asked Do you want to accept these changes?, reply m for [m]ore context.

What happens?:

The replacement (i.e., prepending "a" to the page text) is done again before showing more context.

>>> Wikipedie:Pískoviště <<<
@@ -1 +1 @@
- {{Tento řádek neměňte}}
+ a{{Tento řádek neměňte}}

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit): m
@@ -1,4 +1,4 @@
- {{Tento řádek neměňte}}
+ aa{{Tento řádek neměňte}}
  <!-- ************  Prosíme, NEMĚŇTE nic nad tímto řádkem.  Díky.  ************ -->

  == Bábovičky ==

Do you want to accept these changes? ([y]es, [N]o, [e]dit original, edit
[l]atest, open in [b]rowser, [m]ore context, [a]ll, [q]uit):

What should have happened instead?:

No other changes are made.

Software version:

Pywikibot: [ssh] pywikibot-core.git (c5beb1d, g18595, 2024/04/19, 17:24:33, master)
Release version: 9.1.0.dev0
packaging version: 21.3
mwparserfromhell version: 0.6.5
wikitextparser version: n/a
requests version: 2.31.0
  cacerts: [redacted]
    certificate test: ok
Python: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]

Event Timeline

Xqt added subscribers: Dvorapa, Xqt.

The m(ore command was introduced with rPWBC17263c7 in release 3.0.20180603 and this probem was already there. I guess that only -regex is affected.

Not really. You can easily make a recursive rule without regex, like "a" -> "aa".

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

[pywikibot/core@master] [bugfix] move replacement out of the loop within ReplaceRobot.treat()

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

Change #1022465 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] cleanup ReplaceRobot.treat(), move statements outside the loop

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

matej_suchanek assigned this task to Xqt.
matej_suchanek removed a project: Patch-For-Review.