Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: dan.bolser [...] gmail.com
Cc:
AdminCc:

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



Subject: Stray warnings when creating a page...
Date: Tue, 18 Nov 2008 17:25:34 +0000
To: bug-MediaWiki-API [...] rt.cpan.org
From: "Dan Bolser" <dan.bolser [...] gmail.com>
hihi I am using MediaWiki::API to create a series of pages. I keep getting the following non-fatal error: Use of uninitialized value in subroutine entry at /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Encode.pm line 196. The relevant part of my code looks like this: my $pagename = "Test:EntryPoint:$segId"; my $page = $mw->get_page( { title => $pagename } ); if ( defined($page->{missing}) ) { my $pagetext = " This is an entry point ($segId). {{EntryPoint | id = $segId | size = $ref->{$segId}{'size'} | start = $ref->{$segId}{'start'} | end = $ref->{$segId}{'stop'} | class = $ref->{$segId}{'class'} | orientation = $ref->{$segId}{'orientation'} | subparts = $ref->{$segId}{'subparts'} }} "; my $timestamp = $ref->{timestamp}; $mw->edit( { action => 'edit', title => $pagename, basetimestamp => $timestamp, # to avoid edit conflicts text => $pagetext } ); } else{ warn "$pagename already exists\nskipping\n"; next; } #exit; } I get one of the above style warnings per page. I guess its not serious, because other than that its all working fine :D Dan. -- http://network.nature.com/profile/dan
the api module utf-8 encodes all parameters. Can you check that no undefined value is getting into the hashref you are sending?
On Tue Nov 18 12:26:49 2008, dan.bolser wrote: Show quoted text
> Use of uninitialized value in subroutine entry at > /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Encode.pm line 196.
the problem is a warning from the Encode module due to "undefined" parameters sent to the API. You probably don't want that anyway. However, I have now made it skip over thise so no more warnings.
Subject: Re: [rt.cpan.org #41036] Stray warnings when creating a page...
Date: Thu, 20 Nov 2008 10:11:20 +0000
To: bug-MediaWiki-API [...] rt.cpan.org
From: "Dan Bolser" <dan.bolser [...] gmail.com>
2008/11/19 Jools Smyth via RT <bug-MediaWiki-API@rt.cpan.org>: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=41036 > > > On Tue Nov 18 12:26:49 2008, dan.bolser wrote:
>> Use of uninitialized value in subroutine entry at >> /usr/lib/perl5/5.8.8/i386-linux-thread-multi/Encode.pm line 196.
> > the problem is a warning from the Encode module due to "undefined" > parameters sent to the API. You probably don't want that anyway. > However, I have now made it skip over thise so no more warnings.
Hey Jools, Sorry I didn't get round to checking my code as you asked above. TBH, I don't think I was passing any undef values to the API, but its always worth checking... I'll let you know. I guess it makes sense to suppress these warnings and fall back on the standard errors if a method call fails for any reason. Thanks very much for the cool code - it makes programmatic interaction to WP with Perl so easy! All the best, Dan. Show quoted text
> > > > >
-- http://network.nature.com/profile/dan
On Thu Nov 20 05:11:31 2008, dan.bolser wrote: Show quoted text
> Sorry I didn't get round to checking my code as you asked above. TBH, > I don't think I was passing any undef values to the API, but its > always worth checking... I'll let you know.
I suspected that timestamp might have been undefined, but that was just a guess. The only way I was able to reproduce the warning was when I did send undefined values. (Which originated from the parameter utf-8 encoding loop). Show quoted text
> I guess it makes sense to suppress these warnings and fall back on the > standard errors if a method call fails for any reason. Thanks very > much for the cool code - it makes programmatic interaction to WP with > Perl so easy!
Most welcome. I used to use a screen scraping Mediawiki module, but with every new mediawiki version it seemed to break, and with the API becoming mature it seemed a good idea to switch to it. I've always had the intention of doing a higher level module on top of this one, but it seems others are doing that now, but I might still tackle it. (Which would make certain actions simpler) Thanks for your kind remarks, and it makes it worthwhile when others find it useful. Please do review/rate my module (http://cpanratings.perl.org/rate/?distribution=MediaWiki-API) ;-) Best Regards Jools