Skip Menu |

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

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

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

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



Howdy, The following code returns this error: "Not an ARRAY reference at /usr/local/share/perl/5.8.8/MediaWiki/API.pm line 425." Code that fails my $mw = MediaWiki::API->new(); $mw->{config}->{api_url} = 'http://en.wikipedia.org/w/api.php'; my $result = $api->list ({ action => 'query', list => 'backlinks', bltitle => 'Biafra' }) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details}; Note that it really does not matter what title is used. This is a valid query, as the following code returns results, just not in a simple array. my $mw = MediaWiki::API->new(); $mw->{config}->{api_url} = 'http://en.wikipedia.org/w/api.php'; my $result = $api->list ({ action => 'query', list => 'backlinks', bltitle => 'Biafra' }) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details}; Basically the module is returning an error as if there is a problem with it.
Hi, Thanks for the report. The problem seems to be that the mediawiki API returns results inconsistenly through the JSON api. This list should be an array, and looking at the xml, the mapping here is strange. I have written to the mediawiki api list, and hope to get a reply. On earlier versions of my module I was using XML which was working except for a small bug with the pure perl XML parser. Because of that and the lack of speed I moved to the JSON format but I am not so sure mediawiki's support for it is well tested. Depending on the answer I get from the developers I might consider changing back to XML (and making the script require one of the faster xml parsers for perl). In the meantime, you can use the $mw->api call and loop through the results with my $result = $mw->api ({ action => 'query', list => 'backlinks', bltitle => 'Biafra' }) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details}; while ( ( $pageid, $ref ) = each %{ $result->{query}->{backlinks} } ) { print $ref->{pageid} . " - " . $ref->{title} . "\n"; }
The way this works has now been changed on the mediawiki-api. http://lists.wikimedia.org/pipermail/mediawiki-api/2008-August/000660.html I will leave this bug open until Mediawiki reaches the next stable release with this api change.
Show quoted text
> I will leave this bug open until Mediawiki reaches the next stable > release with this api change.
With the release of mediawiki 1.14 which corrects this issue, I am now closing this bug.
From: dan.bolser [...] gmail.com
On Thu Feb 26 15:30:07 2009, exobuzz wrote: Show quoted text
> > I will leave this bug open until Mediawiki reaches the next stable > > release with this api change.
> > With the release of mediawiki 1.14 which corrects this issue, I am now > closing this bug.
Does this mean MediaWiki::API is officially unsupported for versions of MW before 1.14? If so, I'll refrain from reporting bugs in sites with those versions. Cheers, Dan.
Show quoted text
> Does this mean MediaWiki::API is officially unsupported for versions of > MW before 1.14? If so, I'll refrain from reporting bugs in sites with > those versions.
It means if there is a bug due to an old mediawiki, then there isn't much I can do about it. If you comment on an old bug, unless it really needs to be reopened please keep the status as resolved/closed etc.
From: dan.bolser [...] gmail.com
On Wed Mar 16 14:57:00 2011, exobuzz wrote: Show quoted text
> > Does this mean MediaWiki::API is officially unsupported for versions of > > MW before 1.14? If so, I'll refrain from reporting bugs in sites with > > those versions.
> > It means if there is a bug due to an old mediawiki, then there isn't > much I can do about it. If you comment on an old bug, unless it really > needs to be reopened please keep the status as resolved/closed etc.
Sorry, I'm not deliberately re-opening these bugs. As a reporter I don't have the option to set the bug status in my replies. I guess they are being automatically re-opened by the act of replying? About the above, I thought that bugs with old versions of MW could still be resolved, so long as they are 'forward compatible' with the latest MW versions. For example, some old sites don't respect some new api parameters, and the mediawiki::api correctly fails with an error. However, I've seen versions that fail differently from others, and in those cases the exception isn't caught by the mediawiki::api code. When I track this down I was planning to report it as a bug, so that the code can be used on sites with those versions... does that make sense? Cheers, Dan.
Show quoted text
> Sorry, I'm not deliberately re-opening these bugs. As a reporter I don't > have the option to set the bug status in my replies. I guess they are > being automatically re-opened by the act of replying?
May I suggest you try instead the discussion forum rather than the bugtracker. No-one likes bugs, and many of your queries do seem to be more that you need some help/guidance which would fit the forum better. Show quoted text
> When I track this down I was planning to report it as a bug, so that the > code can be used on sites with those versions... does that make sense?
Not sure it does - perhaps you could explain (not here please). note the bug this ticket is in regards to inconsistent json formatting and not backward compatibility with mediawiki.