Permalink
Browse files

Don't use an invalid undefined assertion by default

In the case where no assertion was provided, the undefined
value was used, which is then sent to the wiki, which
considers it invalid. This prevented editing and other
interactions.
  • Loading branch information...
1 parent be7aeee commit 84bf80036ba160d99cfbd46675f12b08e0a757c3 Mike.lifeguard committed Nov 21, 2011
Showing with 13 additions and 3 deletions.
  1. +1 −0 Changes
  2. +2 −2 lib/MediaWiki/Bot.pm
  3. +10 −1 t/00-init.t
View
@@ -2,6 +2,7 @@ Changelog for {{$dist->name}}
{{$NEXT}}
* Edits may be marked as major once again
+ * Don't use an invalid undefined assertion by default
v3.4.2 2011-08-26
* Silence spurious warnings in the test suite
@@ -166,7 +166,7 @@ sub new {
my $self = bless({}, $package);
$self->{errstr} = '';
- $self->{assert} = $assert;
+ $self->{assert} = $assert if $assert;
$self->{operator} = $operator;
$self->{debug} = $debug || 0;
$self->{api} = MediaWiki::API->new({
@@ -638,8 +638,8 @@ sub edit {
basetimestamp => $lastedit, # Guard against edit conflicts
starttimestamp => $tokentime, # Guard against the page being deleted/moved
bot => $markasbot,
- assert => $assert,
section => $section,
+ ( $assert ? (assert => $assert) : ()),
};
if ($is_minor) {
$hash->{minor} = 1;
View
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More 0.96 tests => 4;
+use Test::More 0.96 tests => 5;
BEGIN {
my $bail_diagnostic = <<'END';
There was a problem loading the module. Typically,
@@ -71,3 +71,12 @@ subtest 'diag-two' => sub {
is( $test_two->{api}->{config}->{api_url}, 'http://127.0.0.1/w/api.php', 'api.php with undef path is OK');
like($test_two->{api}->{ua}->agent(), qr/\Q$operator\E/, 'operator appears in the useragent');
};
+
+subtest 'no assert' => sub {
+ plan tests => 1;
+ my $no_assert_bot = MediaWiki::Bot->new({
+ host => $host,
+ });
+ ok( not exists $bot->{assert} ) or diag explain $bot;
+};
+

0 comments on commit 84bf800

Please sign in to comment.