r25347 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25346‎ | r25347 | r25348 >
Date:11:04, 31 August 2007
Author:aaron
Status:old
Tags:
Comment:
*Fix fucked up schema. Make ip value NULLable to avoid stupid collisions when people review the same revision, since the IP for users was recorded as '', the ip,rev,type tuplet would be matched. Record NULL instead of '' for IPs.
Modified paths:
  • /trunk/extensions/Review/Review.pg.sql (modified) (history)
  • /trunk/extensions/Review/Review.php (modified) (history)
  • /trunk/extensions/Review/Review.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Review/Review.sql
@@ -7,7 +7,7 @@
88 val_type int NOT NULL,
99 val_value int(2) NOT NULL,
1010 val_comment varchar(255) NOT NULL default '',
11 - val_ip varchar(255) NOT NULL default '',
 11+ val_ip varchar(255) NULL default '',
1212
1313 PRIMARY KEY (val_id),
1414 UNIQUE KEY (val_user,val_revision,val_type),
Index: trunk/extensions/Review/Review.pg.sql
@@ -11,7 +11,7 @@
1212 val_type SMALLINT NOT NULL DEFAULT 1,
1313 val_value SMALLINT NOT NULL,
1414 val_comment TEXT NOT NULL DEFAULT '',
15 - val_ip TEXT NOT NULL DEFAULT '',
 15+ val_ip TEXT NULL,
1616 PRIMARY KEY (val_id)
1717 );
1818
Index: trunk/extensions/Review/Review.php
@@ -244,7 +244,8 @@
245245
246246 $fname = 'wfReviewExtensionReadLastForm' ;
247247 $dbw =& wfGetDB( DB_MASTER );
248 - $user_ip = $wgUser->getID() == 0 ? $wgUser->getName() : "" ;
 248+ # Avoid user/ip tuplet unique index collisions
 249+ $user_ip = $wgUser->getID() == 0 ? $wgUser->getName() : NULL ;
249250
250251 # Read form values
251252 $oldrev = $wgRequest->getInt ( 'review_oldid' ) ;
@@ -311,7 +312,7 @@
312313
313314 # Insert new ratings into the database
314315 if ( count ( $new_data ) > 0 ) {
315 - $dbw->begin () ;
 316+ $dbw->begin() ;
316317 foreach ( $new_data AS $key => $value ) {
317318 $data = array (
318319 'val_user' => $value->val_user ,
@@ -322,7 +323,9 @@
323324 'val_comment' => $value->val_comment ,
324325 'val_ip' => $value->val_ip ,
325326 ) ;
326 - $dbw->replace( 'validate', array('val_user') , $data ) ;
 327+ $name = $value->val_user ? 'val_user' : 'val_ip';
 328+
 329+ $dbw->replace( 'validate', array( array($name,'val_revision','val_type') ), $data ) ;
327330 }
328331 $dbw->commit();
329332 }

Status & tagging log