Skip to content

Commit

Permalink
Bug fix: redirects to different pages are included in Lua table
Browse files Browse the repository at this point in the history
Fix a bug where redirects to different are sometimes included in the Lua
table. This happens when the page in question includes a normal link to
the page being queried, and is also a redirect targeting a different
page. This occurs because fetch_template_metadata uses the backlinks()
method instead of the redirects() method. The backlinks method uses the
backlinks generator in the query API, which returns all links to the
page, not just redirects that have the page as the target.

Fixes #1
  • Loading branch information
mrstradivarius committed Feb 20, 2024
1 parent c011807 commit f7d544d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions stradbot/dabtemplates/dabtemplates.py
Expand Up @@ -42,12 +42,7 @@ def fetch_template_metadata(template_generator, excluded):
if page.title(with_ns=False) in excluded:
continue
redirects = []
for redirect in page.backlinks(
follow_redirects=False,
filter_redirects=True,
namespaces=[10],
content=False,
):
for redirect in page.redirects(namespaces=[10], content=False):
redirects.append(redirect.title(with_ns=False))
redirects.sort()
templates.append(
Expand Down

0 comments on commit f7d544d

Please sign in to comment.