Page MenuHomePhabricator

SearchTestCase.test_search is failing on test.wikipedia.org
Closed, ResolvedPublic

Description

https://travis-ci.org/wikimedia/pywikibot/jobs/399543994#L1579

__________________________ SearchTestCase.test_search __________________________
self = <tests.site_tests.SearchTestCase testMethod=test_search>
    def test_search(self):
        """Test the site.search() method."""
        mysite = self.site
        try:
            se = list(mysite.search("wiki", total=100, namespaces=0))
            self.assertLessEqual(len(se), 100)
            self.assertTrue(all(isinstance(hit, pywikibot.Page)
                                for hit in se))
>           self.assertTrue(all(hit.namespace() == 0 for hit in se))
E           AssertionError: False is not true

Event Timeline

Dalba triaged this task as High priority.Jul 3 2018, 3:00 PM

No search results?

No, there are search results, but there are results which are not from the main namespace: Page('Draft talk:Draft:Testing AFCH').

Strange thing is that the page does not exist: https://test.wikipedia.org/wiki/Draft_talk:Draft:Testing_AFCH

But it indeed is included in the API result:

"82098": {
    "pageid": 82098,
    "ns": 0,
    "title": "Draft talk:Draft:Testing AFCH",
    "index": 91,
    "contentmodel": "wikitext",
    "pagelanguage": "en",
    "pagelanguagehtmlcode": "en",
    "pagelanguagedir": "ltr",
    "touched": "2015-07-16T12:00:25Z",
    "lastrevid": 233705,
    "length": 49,
    "new": "",
    "protection": [],
    "restrictiontypes": [
        "edit",
        "move"
    ]
},

https://test.wikipedia.org/w/api.php?gsrsearch=wiki&gsrwhat=text&prop=info|imageinfo|categoryinfo&inprop=protection&iiprop=timestamp|user|comment|url|size|sha1|metadata&iilimit=max&generator=search&action=query&indexpageids=&continue=&gsrnamespace=0&gsrlimit=100

@Anomie , do you know what is going on here?
Specifically, why is there a search result for a page that does not exist, and why is it marked as namespace: 0 when Draft talk namespace number should be 119?

The page "Draft:Testing AFCH" in the "Draft talk" namespace does not exist. But that's not what's being returned here.

The page "Draft talk:Draft:Testing AFCH" in the main namespace does exist, presumably due to some bug around July 2015 when it was created. You can see it via the web UI by using the page ID to access it: https://test.wikipedia.org/wiki/?curid=82098.

The draft and draft talk namespaces were recently configured on testwiki (T198143: Enable Draft namespace on testwiki ) by Community-Tech (@MusikAnimal).

Ah, that explains it. They apparently forgot to run maintenance/namespaceDupes.php after adding the namespace.

Sorry, didn't know about the namespaceDupes maintenance script. We'll get this ran ASAP!

Dvorapa moved this task from Backlog to Upstream issues on the Pywikibot board.
Dvorapa moved this task from Test failures to Upstream issues on the Pywikibot-tests board.

Sorry, I forgot to run it when I did the deploy. Done now.

Dalba claimed this task.

Wow, that was quick! Thanks, everyone! ❤️