jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Search: User pref independent and only srredirects on < 1.23 ......................................................................
[FIX] Search: User pref independent and only srredirects on < 1.23
The search is independent of the user preferences, so they by default always return from namespace 0.
In 1.23 the parameter 'srredirect' for 'list=search' was removed because it always return redirects.
Change-Id: I7a9ad89a95ecd611acaca61b1604f95d3f000615 --- M pywikibot/site.py M tests/site_tests.py 2 files changed, 4 insertions(+), 4 deletions(-)
Approvals: Mpaa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index a5c1754..238c507 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -3250,7 +3250,8 @@ @param namespaces: search only in these namespaces (defaults to 0) @type namespaces: list of ints, or an empty list to signal all namespaces - @param getredirects: if True, include redirects in results + @param getredirects: if True, include redirects in results. Since + version MediaWiki 1.23 it will always return redirects. @param content: if True, load the current content of each iterated page (default False)
@@ -3268,7 +3269,7 @@ gsrsearch=searchstring, gsrwhat=where, namespaces=namespaces, step=step, total=total, g_content=content) - if getredirects: + if getredirects and LV(self.version()) < LV('1.23'): srgen.request["gsrredirects"] = "" return srgen
diff --git a/tests/site_tests.py b/tests/site_tests.py index 778d5e6..b2fb360 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -776,8 +776,7 @@ self.assertLessEqual(len(se), 100) self.assertTrue(all(isinstance(hit, pywikibot.Page) for hit in se)) - search_ns = [ns.id for ns in mysite.get_searched_namespaces(force=True)] - self.assertTrue(all(hit.namespace() in search_ns for hit in se)) + self.assertTrue(all(hit.namespace() == 0 for hit in se)) for hit in mysite.search("common", namespaces=4, total=5): self.assertIsInstance(hit, pywikibot.Page) self.assertEqual(hit.namespace(), 4)