Skip Menu |

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

Report information
The Basics
Id: 56335
Status: resolved
Worked: 10 min
Priority: 0/
Queue: MediaWiki-API

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.29
Fixed in: (no value)



Subject: Breaking login change in mediawiki
https://bugzilla.wikimedia.org/show_bug.cgi?id=23076 Changes the login routine to require a seperate step with tokens. Will poke and NMU if required.
On Tue Apr 06 20:42:01 2010, overlordq@gmail.com wrote: Show quoted text
> https://bugzilla.wikimedia.org/show_bug.cgi?id=23076 > > Changes the login routine to require a seperate step with tokens. Will > poke and NMU if required.
Thanks for this. I will be able to look into it hopefully this week. Feel free to post patches before hand. I have a single function that handles various tokens, so it might be good to use that, or being more complicated it might be easier for a separate function. I need to remind myself. I am happy to receive patches if someone wants to fix this sooner. This of course only affects people using our login shortcut. if users are using the API call directly they can continue to do so, but will need to adjust their code accordingly. thanks again.
Pretty sure this is working, no guarantees though, just testing logging in.
Subject: 0001-Patch-for-new-login-system.patch
From e9de08c3aab4d4163a2263c62a691b6a396ffeb4 Mon Sep 17 00:00:00 2001 From: OverlordQ <overlordq@gmail.com> Date: Wed, 7 Apr 2010 01:57:05 +0000 Subject: [PATCH] Patch for new login system --- lib/MediaWiki/API.pm | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/MediaWiki/API.pm b/lib/MediaWiki/API.pm index 88bb182..3f66bfe 100644 --- a/lib/MediaWiki/API.pm +++ b/lib/MediaWiki/API.pm @@ -40,11 +40,11 @@ MediaWiki::API - Provides a Perl interface to the MediaWiki API (http://www.medi =head1 VERSION -Version 0.29 +Version 0.30 =cut -our $VERSION = "0.29"; +our $VERSION = "0.30"; =head1 SYNOPSIS @@ -219,11 +219,21 @@ sub login { # reassign hash reference to the login section my $login = $ref->{login}; - return $self->_error( ERR_LOGIN, 'Login Failure - ' . $login->{result} ) - unless ( $login->{result} eq 'Success' ); - # everything was ok so return the reference - return $login; + # Do login token checking + if( $login->{result} eq 'Success' ) { + return $login; + } elsif ( $login->{result} eq 'NeedToken' ) { + my $token = $login->{token}; + $query->{lgtoken} = $token; + #Resubmit previous request with token + return undef unless ( $ref = $self->api( $query ) ); + $login = $ref->{login}; + + return $login if ( $login->{result} eq 'Success' ); + } + + return $self->_error( ERR_LOGIN, 'Login Failure - ' . $login->{result} ) } =head2 MediaWiki::API->api( $query_hashref, $options_hashref ) -- 1.7.0.4
Many thanks for the report and patch. I have incorporated your changes with some minor changes and a version 0.30 should appear on cpan shortly.