[Regression] Delete autoblocks when removing autoblock flag
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 23 Mar 2014 16:27:02 +0000 (17:27 +0100)
committerumherirrender <umherirrender_de.wp@web.de>
Sun, 23 Mar 2014 16:27:02 +0000 (17:27 +0100)
Since I5403f6e1d7f8f07273cd5da8068b928fdddcdfc9 on reblock the block
will be updated and not deleted/inserted and that update did not trigger
a delete of existing autoblocks.

Bug: 62748
Change-Id: I50384a41d819689944907e653e2495391253831b

includes/Block.php

index 3575b9d..08428b4 100644 (file)
@@ -452,12 +452,22 @@ class Block {
 
                $affected = $dbw->affectedRows();
 
-               $dbw->update(
-                       'ipblocks',
-                       $this->getAutoblockUpdateArray(),
-                       array( 'ipb_parent_block_id' => $this->getId() ),
-                       __METHOD__
-               );
+               if ( $this->isAutoblocking() ) {
+                       // update corresponding autoblock(s) (bug 48813)
+                       $dbw->update(
+                               'ipblocks',
+                               $this->getAutoblockUpdateArray(),
+                               array( 'ipb_parent_block_id' => $this->getId() ),
+                               __METHOD__
+                       );
+               } else {
+                       // autoblock no longer required, delete corresponding autoblock(s)
+                       $dbw->delete(
+                               'ipblocks',
+                               array( 'ipb_parent_block_id' => $this->getId() ),
+                               __METHOD__
+                       );
+               }
 
                $dbw->endAtomic( __METHOD__ );