Skip Menu |

This queue is for tickets about the MediaWiki-API CPAN distribution.

Report information
The Basics
Id: 41102
Status: resolved
Priority: 0/
Queue: MediaWiki-API

People
Owner: Nobody in particular
Requestors: DCOLLINS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.20
Fixed in: (no value)



Subject: MediaWiki::API crashing
A user reported the following bug: I see it's more than just tests: my bot dies after a timeout producing: Use of uninitialized value in length at /usr/local/share/perl/5.8.8/MediaWiki/API.pm line 271. Can't use an undefined value as a HASH reference at /usr/local/share/perl/5.8.8/ Perlwikipedia.pm line 364. ---- That's what I get when I try to execute code from "synopsis" in http://search.cpan.org/~exobuzz/MediaWiki-API-0.21/lib/ MediaWiki/API.pm (my version is 0.21, so the latest): Use of uninitialized value in length at /usr/local/share/perl/5.8.8/MediaWiki/API.pm line 282. 2: http://en.wikipedia.org/w/api.php returned a zero length string at ./testmwapi.pl line 8. ---- The bug was filed at http://code.google.com/p/perlwikipedia/issues/detail?id=13 and appears to be upstream.
Show quoted text
> That's what I get when I try to execute > code from "synopsis" in > http://search.cpan.org/~exobuzz/MediaWiki-API-0.21/lib/ > MediaWiki/API.pm (my version is 0.21, so the latest): > Use of uninitialized value in length at > /usr/local/share/perl/5.8.8/MediaWiki/API.pm > line 282. > 2: http://en.wikipedia.org/w/api.php returned a zero length string at > ./testmwapi.pl > line 8.
I am unable to reproduce this. Do you have some code which reproduces this error?. The line in question with (Use of uninitialized value in length at) means that $response->decoded_content is undefined. I don't actually check for this, because I assume that if $response->is_success is ok then there will be some decoded content (even if it is an empty string). I've done a search on the web and I found decoded_content: Returns the content with any Content-Encoding undone and the raw content encoded to perl's Unicode strings. If the Content-Encoding or charset of the message is unknown this method will fail by returning undef. so maybe I need to force this, but the charset/encoding shouldn't be unknown really if the web server is correctly configured. I should check this though and return a different error perhaps. might help to debug the problem. would be easier with some code which reproduces the problem though.
The user reports that the code under synopsis in the POD causes the error. I'm guessing that it's a LWP::UserAgent or HTTP::Response error, feel free to send it to them.
On Thu Nov 20 14:57:42 2008, DCOLLINS wrote: Show quoted text
> The user reports that the code under synopsis in the POD causes the > error. I'm guessing that it's a LWP::UserAgent or HTTP::Response error, > feel free to send it to them.
Actually, the error they are having may be a different one. My code is somewhat broken in some cases I think. I'll fix it up.
I have uploaded a new version which should appear shortly. (or you can get it from http://malus.exotica.org.uk/~buzz/cpan/MediaWiki-API-0.22.tar.gz) The http error handling is much improved, as I had cut some corners a bit, but I believe the problem the user is having is down to a connectivity issue, or LWP problem. However, I have made some changes which might improve it for him, or at least give more information to the cause. This includes telling HTTP::Message to ignore character encoding when decoding content (since the JSON module will handle this and assume UTF-8) and also catching problems HTTP::Message might have when decoding. Please can you ask the user to try this version out and let me know how he gets on.
Well, this problem seems to have been fixed by the user in question. Setting to resolved