jpatokal / mediawiki-gateway

Ruby framework for MediaWiki API manipulation
Other
133 stars 50 forks source link

Fix from vs. continue #58

Closed blackwinter closed 10 years ago

blackwinter commented 10 years ago

Recent MediaWiki versions (>= 1.19?) don't return @apfrom anymore. Instead, @apcontinue is returned in the response body.

This is inherently untestable with FakeMediaWiki and may not work on older MediaWiki versions. But testing against a live instance shows the effect:

# before:
MediaWiki::Gateway.new('https://en.wikipedia.org/w/api.php').list('Media').size #=> 500

# after:
MediaWiki::Gateway.new('https://en.wikipedia.org/w/api.php').list('Media').size #=> 2373
jpatokal commented 10 years ago

Otherwise cool, but I'd prefer not to break backward compatibility. Could you tweak the XPath to match either? I don't think ReXML supports (@apfrom|@apcontinue), since that's XPath 2, but something along the lines of @*[name()='apfrom' or name()='apcontinue'] should do the trick.

blackwinter commented 10 years ago

I can do that. In that case, however, I'd like to extract the logic that deals with continuing a query into a shared method. There's a lot of duplication and adding more logic doesn't help the fact at all. Would you agree and, if so, should it take place in this pull request or should I open a new one?

Also, backlinks and contributions are already continue-only. Should they be changed, too?

For future reference, MediaWiki API 2.0 is going to introduce a new "continue" syntax. At some point this library probably needs to take differing API capabilities into account.

jpatokal commented 10 years ago

Sounds good to me, feel free to add to this pull request. And the more fixes the merrier ;)

API 2.0 is most likely to be somebody else's problem...

blackwinter commented 10 years ago

Finished first pass. Still need to add documentation and do some more testing. Should be ready to push some time tomorrow.

(Turns out that #56 isn't settled yet, though. More on that later.)

blackwinter commented 10 years ago

Done: b489c94. Please let me know if you have any comments or want me to change anything.

jpatokal commented 10 years ago

Sweet, that's so much better than before. Thanks a million!