Page MenuHomePhabricator

Site.pagereferences() may iterate the same page twice
Closed, ResolvedPublic

Description

Summary
Site.pagereferences() may return the same page twice under certain conditions.

Details
If only_template_inclusion=False and with_template_inclusion=True (the default settings), then pagereferences() combines the results of pagebacklinks() and page_embeddedin().
Since both iterables can contain the same pages, duplicates may occur.

Example
On https://en.wikipedia.org/wiki/Special:WhatLinksHere?target=File%3ABoA+%E2%80%93+Woman.png&namespace=&limit=50, [[File:BoA - Woman.png]] is listed twice:

  • once as a backlink with redirects,
  • once as a transclusion.

Expected behavior
pagereferences() should not return duplicates (except it is explicitly wanted to prevent huge memory usage)

Details

Related Changes in Gerrit:

Event Timeline

Xqt triaged this task as Medium priority.Sep 25 2025, 8:15 AM

Change #1320125 had a related patch set uploaded (by Mahveotm; author: Mahveotm):

[pywikibot/core@master] [bugfix] Avoid duplicate page references

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

Change #1320125 merged by Xqt:

[pywikibot/core@master] [bugfix] Avoid duplicate page references

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