Skip to content

Commit

Permalink
Don't edit the operator's talk page if edit encounters errors
Browse files Browse the repository at this point in the history
This is bad because
  - this is fragile -- the edit routines don't do proper error handling
  - this is annoying
    - this might encourage operators to omit the operator parameter
      to the constructor to avoid getting these notices
  - this removes control of error handling from the developer
  - this only deals with errors encountered while editing

Just remove it and let devs do the right thing.

Fixes gh-68
  • Loading branch information
doherty committed Aug 22, 2014
1 parent 5fcb0aa commit cd9fe39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog for {{$dist->name}}
- Use symbolic constants instead of magic numbers, and add
MediaWiki::Bot::Constants so developers can use them too [gh-59]
- Support solving CAPTCHAs [gh-2]
- Remove automatic editing of the bot operator's talk page [gh-68]

5.005007 2013-11-27
- Don't fail due to new Module::Pluggable warnings
Expand Down
40 changes: 5 additions & 35 deletions lib/MediaWiki/Bot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -731,45 +731,15 @@ sub edit {
# You need to solve the CAPTCHA, then retry the request with the ID in
# this error response and the solution.
if (exists $res->{edit}->{captcha}) {
carp "Encountered a CAPTCHA";
$self->_handle_api_error({
return $self->_handle_api_error({
code => ERR_CAPTCHA,
details => $res->{edit}->{captcha}
details => 'captcharequired: This action requires that a CAPTCHA be solved',
captcha => $res->{edit}->{captcha},
});
}

if ($self->{operator}) {
my $optalk = $self->get_text('User talk:' . $self->{operator});
if (defined($optalk)) {
carp "Sending warning!" if $self->{debug};
if ($self->{'username'}) {
$self->edit(
page => "User talk:$self->{'operator'}",
text => $optalk
. "\n\n==Error with $self->{'username'}==\n"
. "$self->{'username'} needs to be logged in! ~~~~",
summary => 'bot issue',
is_minor => 0,
assert => '',
);
croak "$self->{'username'} got logged out" if $self->{debug};
}
else { # The bot wasn't ever supposed to be logged in
$self->edit(
page => "User talk:$self->{'operator'}",
text => $optalk
. "\n\n==Error with your bot==\n"
. "Your bot encountered an error. ~~~~",
summary => 'bot issue',
is_minor => 0,
assert => '',
);
croak "Bot encountered an error while editing" if $self->{debug};
}
}
}
return;
return $self->_handle_api_error();
}

return $res;
}

Expand Down

0 comments on commit cd9fe39

Please sign in to comment.