Page MenuHomePhabricator

textlib.replace_links() does not work as expected
Open, HighPublic

Description

The following illustrates it. [[heads up]] is a Redirect to [[Liste von Pokerbegriffen#heads up]]
[t]arget option unlinks to the new tarket ignoring section link:

>>> 1:1 <<<
pieler am Tisch sitzen, siehe [[heads up]]
* einen bestimmten Beziehungs
Should the link target to Liste von Pokerbegriffen? (Do [N]ot change, [u]nlink,
Change link [t]arget, Change [l]ink target and label): t
@@ -3 +3 @@
- * eine Phase beim Poker, bei der nur noch zwei Spieler am Tisch sitzen, siehe
[[heads up]]
+ * eine Phase beim Poker, bei der nur noch zwei Spieler am Tisch sitzen, siehe
Liste von Pokerbegriffen

Change [l]ink changes the link but also ignores section:

>>> 1:1 <<<
pieler am Tisch sitzen, siehe [[heads up]]
* einen bestimmten Beziehungs
Should the link target to Liste von Pokerbegriffen? (Do [N]ot change, [u]nlink,
Change link [t]arget, Change [l]ink target and label): l
@@ -3 +3 @@
- * eine Phase beim Poker, bei der nur noch zwei Spieler am Tisch sitzen, siehe
[[heads up]]
+ * eine Phase beim Poker, bei der nur noch zwei Spieler am Tisch sitzen, siehe
[[Liste von Pokerbegriffen]]

n.b. [n]o change and [u]nlink works.

The command line was:

pwb.py disambredir -lang:de

Event Timeline

Xqt raised the priority of this task from to Medium.
Xqt updated the task description. (Show Details)
Xqt added a project: Pywikibot.
Xqt subscribed.

Okay I accidentally inverted the logic and it replaced the section with the other (disabled) option. And this option would currently use the old label. The first option (Change link target) works as expected as the old link doesn't use a section and that option only changes the target and not the section or label.

EDIT: See T104805#1428798

Change 222927 had a related patch set uploaded (by XZise):
[FIX] Replace section/label according to the names

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

Okay there are actually two issues: The patch 222927 fixes a problem introduced with {c223f448} as I've just confused the options and used the values the other way around. And Change link target is actually an issue due to {ad2cf8aa} because that callback returns a string as a shortcut which is now added directly.

EDIT: See T104805#1428798

Okay this is actually a bug report and a feature request. There is the issue that Change link [t]arget is replacing a link with a string. But Change [l]ink target and label works as expected as it changes the target page and label but uses the old section (there was no section). But I've enabled another option which changes the link target and section but not the label. All issues are fixed in https://gerrit.wikimedia.org/r/222927.

Change 222927 merged by jenkins-bot:
[FIX] Replace with Link if all or only target selected

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

Xqt raised the priority of this task from Medium to Unbreak Now!.Aug 30 2016, 9:01 PM

Reopened because it still doesn't work in a right manner. Illustrating the following case:

source link is [[foo#bar]].
[[foo]] is a redirect to [[baz]]

Now we have the following options:
target gives [[baz#bar|foo#bar]] which looks like a valid link
section gives [[baz|foo#bar]] which breaks the link
link gives [[baz|bar#foo]] which breaks the visual content
complete gives [[baz]] which breaks both, the visual content and the link.
And last but not least the only valid replacement ist missing which is [[bar#baz]] in this case which replaces the whole link in the right way.

• Aklapper lowered the priority of this task from Unbreak Now! to High.Jan 2 2017, 1:16 PM

Obviously not "Unbreak Now!" priority as this has been open for four months. Decreasing.

Xqt renamed this task from handle_links() does not work as expected to textlib.replace_links() does not work as expected.May 26 2017, 5:38 AM
Xqt removed XZise as the assignee of this task.Oct 1 2018, 9:11 AM

Change 491673 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [IMPR] Fix weirdly broken replace_links

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

Change 491886 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [bugfix] Fix behavior of disambredir.py

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

Change 491886 had a related patch set uploaded (by Dvorapa; owner: Dvorapa):
[pywikibot/core@master] [bugfix] Fix behavior of disambredir.py

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

Change 491886 abandoned by Xqt:
[pywikibot/core@master] [bugfix] Fix behavior of disambredir.py

Reason:
No change was made

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

Change #491673 abandoned by JJMC89:

[pywikibot/core@master] [IMPR] Fix weirdly broken replace_links to behave more expectable

Reason:

stale patch that cannot be merged - feel free to unabandon if you will update it

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