Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
What could be the reason for intermittend "badtoken" errors when using MediaWiki::API's edit function?
In my script, sometimes I get that error. When I restart the script, it usually works.
I now inserted code to reconnect to my wiki in case a badtoken happens, but I'm wondering how I could debug the issus as it seems to be non-reproducible.
Update: The reconnect code helped. In my last run of updating 378 entries I received a bad token once. After reconnecting it worked.
my $retries= 3; while ($retries--) { last if $mw->edit( { action => 'edit', title => $pagename, basetimestamp => $timestamp, # to avoid edit conflicts text => $text } ); if ( 3 != $mw->{error}->{code} ) { warn "Don't know how to handle " . $mw->{error}->{details}. ' +('. $mw->{error}->{code} . ')'; exit 1; } if (1 > $retries) { warn "No more retries. Giving up on " . $mw->{error}->{details +}. ' ('. $mw->{error}->{code} . ')'; exit 2; } warn "Reconnecting...\n" if $verbose; $mw->logout(); $mw->login( { lgname => $settings->{USER}, lgpassword => $settings +->{PASS} } ) || die $mw->{error}->{details}. ' ('. $mw->{error}->{code} . ') +'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MediaWiki::API badtoken every now and then
by hippo (Archbishop) on Mar 28, 2018 at 14:44 UTC | |
|
Re: MediaWiki::API badtoken every now and then
by marto (Cardinal) on Mar 28, 2018 at 14:51 UTC | |
by Skeeve (Parson) on Mar 28, 2018 at 14:58 UTC | |
by marto (Cardinal) on Mar 28, 2018 at 15:15 UTC | |
by Skeeve (Parson) on Mar 28, 2018 at 15:45 UTC | |
by marto (Cardinal) on Mar 28, 2018 at 15:59 UTC |