r99964 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99963‎ | r99964 | r99965 >
Date:19:12, 16 October 2011
Author:reedy
Status:ok
Tags:
Comment:
INSERT IGNORE when trying to submit duplicate data (seems to be possible when the server is slow at responding and you submit twice)

Add __METHOD__ to update/insert queries
Modified paths:
  • /trunk/extensions/Contest/includes/ContestDBObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/includes/ContestDBObject.php
@@ -254,7 +254,8 @@
255255 return $dbw->update(
256256 $this->getDBTable(),
257257 $this->getWriteValues(),
258 - array( $this->getFieldPrefix() . 'id' => $this->getId() )
 258+ array( $this->getFieldPrefix() . 'id' => $this->getId() ),
 259+ __METHOD__
259260 );
260261 }
261262
@@ -270,7 +271,9 @@
271272
272273 $result = $dbw->insert(
273274 $this->getDBTable(),
274 - $this->getWriteValues()
 275+ $this->getWriteValues(),
 276+ __METHOD__,
 277+ array( 'IGNORE' )
275278 );
276279
277280 $this->setField( 'id', $dbw->insertId() );
@@ -534,7 +537,8 @@
535538 $success = $dbw->update(
536539 $this->getDBTable(),
537540 array( "$fullField=$fullField" . ( $isNegative ? '-' : '+' ) . $absoluteAmount ),
538 - array( $this->getPrefixedField( 'id' ) => $this->getId() )
 541+ array( $this->getPrefixedField( 'id' ) => $this->getId() ),
 542+ __METHOD__
539543 );
540544
541545 if ( $success && $this->hasField( $field ) ) {
@@ -673,7 +677,8 @@
674678 return $dbw->update(
675679 $this->getDBTable(),
676680 $this->getPrefixedValues( $values ),
677 - $this->getPrefixedValues( $conditions )
 681+ $this->getPrefixedValues( $conditions ),
 682+ __METHOD__
678683 );
679684 }
680685

Status & tagging log