PreviousTarget is now optional when blocking a user
authorAntoine Musso <hashar@users.mediawiki.org>
Sun, 29 May 2011 07:00:52 +0000 (07:00 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Sun, 29 May 2011 07:00:52 +0000 (07:00 +0000)
The API does not seem to give a PreviousTarget field all the time.
This patch also fix the an assertion for ApiBlockTest::testMakeNormalBlock

includes/specials/SpecialBlock.php

index bf06f62..0b846ac 100644 (file)
@@ -633,7 +633,7 @@ class SpecialBlock extends SpecialPage {
                $status = $block->insert();
                if( !$status ) {
                        # Show form unless the user is already aware of this...
-                       if( ( $data['PreviousTarget'] != htmlspecialchars( $block->getTarget() ) ) || !$data['Confirm'] ) {
+                       if( ( array_key_exists('PreviousTarget', $data ) && $data['PreviousTarget'] != htmlspecialchars( $block->getTarget() ) ) || !$data['Confirm'] ) {
                                return array( array( 'ipb_already_blocked', $block->getTarget() ) );
                        # Otherwise, try to update the block...
                        } else {