From a4dba3a1ba766b3bee829dd43f54ad9b2ddb5c53 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 31 Mar 2007 17:23:10 +0000 Subject: [PATCH] Reduce query/transaction count. --- includes/Block.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index d1f96e646a..6257b718e5 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -362,7 +362,6 @@ class Block { wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" ); $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); # Unset ipb_anon_only for user blocks, makes no sense if ( $this->mUser ) { @@ -427,20 +426,20 @@ class Block } else { #Limit is 1, so no loop needed. $retroblockip = $row->rc_ip; - return $this->doAutoblock($retroblockip); + return $this->doAutoblock( $retroblockip, true ); } } } /** * Autoblocks the given IP, referring to this Block. - * @param $autoblockip The IP to autoblock. + * @param string $autoblockip The IP to autoblock. + * @param bool $justInserted The main block was just inserted * @return bool Whether or not an autoblock was inserted. */ - function doAutoblock( $autoblockip ) { + function doAutoblock( $autoblockip, $justInserted = false ) { # Check if this IP address is already blocked $dbw = wfGetDB( DB_MASTER ); - $dbw->begin(); # If autoblocks are disabled, go away. if ( !$this->mEnableAutoblock ) { @@ -489,7 +488,9 @@ class Block return; } # Just update the timestamp - $ipblock->updateTimestamp(); + if ( !$justInserted ) { + $ipblock->updateTimestamp(); + } return; } else { $ipblock = new Block; -- 2.20.1