From f7d544dda3f0b5fc27056a32853b27048a06feda Mon Sep 17 00:00:00 2001 From: "Mr. Stradivarius" Date: Tue, 20 Feb 2024 15:52:04 +0900 Subject: [PATCH] Bug fix: redirects to different pages are included in Lua table 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 --- stradbot/dabtemplates/dabtemplates.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/stradbot/dabtemplates/dabtemplates.py b/stradbot/dabtemplates/dabtemplates.py index 56caaaa..d921078 100644 --- a/stradbot/dabtemplates/dabtemplates.py +++ b/stradbot/dabtemplates/dabtemplates.py @@ -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(