New issue 143 by james.l...@gmail.com: what_links_here regression in 3.2.5
for some wikis
http://code.google.com/p/perlwikipedia/issues/detail?id=143
what_links_here returns nothing for all queries to some wikis, but works
fine on others. Using the example code (included below) returns a list of
pages through release 3.2.4. On 3.2.5 and 3.2.6 it returns nothing.
However, similar queries on other wikis seems to work fine.
After comparing the code between revisions, I tried removing the "bllimit
=> 'max'" line from the what_links_here subroutine. With just this one
change, the example code works again. It seems as if some wikis do not
accept using the 'max' keyword in bllimit. Using a number instead of 'max'
will also fix the problem. Using options e.g. { max => 100 } does not fix
the problem.
#!/usr/bin/perl
#
use Data::Dumper;
use MediaWiki::Bot;
my $bot=MediaWiki::Bot->new();
$bot->set_wiki('www.snpedia.com','/');
my @pages=$bot->what_links_here('SNPedia');
print Dumper(@pages);
Comment #1 on issue 143 by mike.lifeguard: what_links_here regression in
3.2.5 for some wikis
http://code.google.com/p/perlwikipedia/issues/detail?id=143
Thanks for finding this bug. The max setting in the options hashref you
refer to is unrelated to bllimit, so it is unsurprising that this would
have no effect. However, I fail to understand why any wiki would not
accept 'max' as a legal bllimit value. And it's not like you're using an
ancient version of MediaWiki either.
So, I'm not quite sure what's happening here, but I'll be looking into it.
Comment #2 on issue 143 by mike.lifeguard: what_links_here regression in
3.2.5 for some wikis
http://code.google.com/p/perlwikipedia/issues/detail?id=143
It appears that your wiki is encountering an error:
$ cat test.pl && perl test.pl
use strict;
use warnings;
use Data::Dumper;
use lib 'lib';
use MediaWiki::Bot;
my $bot = MediaWiki::Bot->new();
$bot->set_wiki('www.snpedia.com','/');
my @pages = $bot->what_links_here('SNPedia') or die Dumper $bot->{error};
print Dumper \@pages;
$VAR1 = {
'stacktrace' => 'internal_api_error_MWException: Exception
Caught: Internal error in ApiResult::setElement: Attempting to add element
backlinks=500, existing value is 500 at
/home/mike/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/MediaWiki/API.pm
line 414
MediaWiki::API::api(\'MediaWiki::API=HASH(0x20db750)\',
\'HASH(0x1940018)\', \'HASH(0x19408b8)\') called at
/home/mike/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/MediaWiki/API.pm
line 613
MediaWiki::API::list(\'MediaWiki::API=HASH(0x20db750)\',
\'HASH(0x1940018)\', \'HASH(0x19408b8)\') called at lib/MediaWiki/Bot.pm
line 1125
MediaWiki::Bot::what_links_here(\'MediaWiki::Bot=HASH(0x192d220)\',
\'SNPedia\') called at test.pl line 9
',
'details' => 'internal_api_error_MWException: Exception Caught:
Internal error in ApiResult::setElement: Attempting to add element
backlinks=500, existing value is 500',
'code' => 3
};
So this is not a bug in MediaWiki::Bot.
fails while
does not.
The exception is raised at line 152
http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/api/ApiResult.php?view=markup
This function has a header comment which says
" Verifies that value with the same name has not been added before. "
And a server side back trace shows the error was produced along this path
#0 /var/www/html/includes/api/ApiBase.php(974):
wfDebugDieBacktrace('Internal error ...')
#1 /var/www/html/includes/api/ApiResult.php(161):
ApiBase::dieDebug('ApiResult::setE...', 'Attempting to a...')
#2 /var/www/html/includes/api/ApiResult.php(277):
ApiResult::setElement(Array, 'backlinks', 500)
#3 /var/www/html/includes/api/ApiQueryBacklinks.php(200):
ApiResult->addValue('limits', 'backlinks', 500)
#4 /var/www/html/includes/api/ApiQueryBacklinks.php(92):
ApiQueryBacklinks->run()
#5 /var/www/html/includes/api/ApiQuery.php(233):
ApiQueryBacklinks->execute()
#6 /var/www/html/includes/api/ApiMain.php(595): ApiQuery->execute()
#7 /var/www/html/includes/api/ApiMain.php(338): ApiMain->executeAction()
#8 /var/www/html/includes/api/ApiMain.php(322):
ApiMain->executeActionWithErrorHandling()
#9 /var/www/html/api.php(116): ApiMain->execute()
#10 {main}
For the moment I've modified SNPedia's version with
if ($value != $arr[$name]) {
ApiBase :: dieDebug( __METHOD__, "Attempting to add
element $name=$value, existing value is {$arr[$name]}" );
} else {
//ApiBase :: dieDebug( __METHOD__, "Attempting to add
duplicate element $name=$value, existing value is {$arr[$name]}" );
}
which will not complain when setting a duplicate as was true in this case.
I think the error begins at ApiQueryBacklinks.php line 200.