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} . ') +'; }
In reply to MediaWiki::API badtoken every now and then by Skeeve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |