From: Tim Starling Date: Sat, 31 Mar 2007 17:23:10 +0000 (+0000) Subject: Reduce query/transaction count. X-Git-Tag: 1.31.0-rc.0~53523 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=a4dba3a1ba766b3bee829dd43f54ad9b2ddb5c53;p=lhc%2Fweb%2Fwiklou.git Reduce query/transaction count. --- 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;