Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query frees for infinite loop & handling wiki errors #53

Closed
GoogleCodeExporter opened this issue Mar 9, 2016 · 2 comments
Closed

Query frees for infinite loop & handling wiki errors #53

GoogleCodeExporter opened this issue Mar 9, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. site = wiki.Wiki("http://en.wikipedia.org/w/api.php")
   params = {'action':'query',
      'titles' : 'deep lake water cooling',
      'prop':'extracts|images|imageinfo',
      'format' : 'json',
      'iiprop' : 'parsedcomment|url|dimensions|size',
      'generator':'images', 
      'exlimit':10 
      }
  req = wiki.api.APIRequest(site, params) 
2. Searching for two separated words cause the API to freeze, I can get error 
or no result work


What is the expected output? What do you see instead?
based on the wikipedia document it should give me back this result 
http://en.wikipedia.org/w/api.php?action=query&titles=deep%20lake%20water%20cool
ing:&format=jsonfm

{
    "query": {
        "pages": {
            "-2": {
                "ns": 0,
                "title": "Doesntexist",
                "missing": ""
            },
            "-1": {
                "title": "Talk:",
                "invalid": ""
            },
            "15580374": {
                "pageid": 15580374,
                "ns": 0,
                "title": "Main Page"
            }
        }
    }
}
What version of the product are you using? On what operating system?

I have the latest version of wikitools 
Please provide any additional information below.

Original issue reported on code.google.com by Basel.Ma...@gmail.com on 5 Jul 2013 at 2:14

@GoogleCodeExporter
Copy link
Author

Note that wikitools has moved to GitHub. Except for currently outstanding bug 
reports, all new development work will happen there - 
https://github.com/alexz-enwp/wikitools

To fix the specific problem in this case, you need to set the 'redirects' param 
to automatically resolve redirects

params = {'action':'query',
      'titles' : 'deep lake water cooling',
      'prop':'extracts|images|imageinfo',
      'format' : 'json',
      'iiprop' : 'parsedcomment|url|dimensions|size',
      'generator':'images', 
      'exlimit':10,
      'redirects':''
}

This should do what you want. 

The more general problem is that most generator queries with an empty result 
set return nothing.

I've fixed this in 
https://github.com/alexz-enwp/wikitools/commit/22a8b920b53f2afc83bf2621d4e802d33
e201f06

It now "properly" returns [] as an APIListResult object

Original comment by MrZmanwiki@gmail.com on 6 Nov 2013 at 5:17

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Issue 50 has been merged into this issue.

Original comment by MrZmanwiki@gmail.com on 7 Dec 2013 at 10:41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant