Index: trunk/extensions/Review/Review.sql |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | val_type int NOT NULL, |
9 | 9 | val_value int(2) NOT NULL, |
10 | 10 | val_comment varchar(255) NOT NULL default '', |
11 | | - val_ip varchar(255) NOT NULL default '', |
| 11 | + val_ip varchar(255) NULL default '', |
12 | 12 | |
13 | 13 | PRIMARY KEY (val_id), |
14 | 14 | UNIQUE KEY (val_user,val_revision,val_type), |
Index: trunk/extensions/Review/Review.pg.sql |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | val_type SMALLINT NOT NULL DEFAULT 1, |
13 | 13 | val_value SMALLINT NOT NULL, |
14 | 14 | val_comment TEXT NOT NULL DEFAULT '', |
15 | | - val_ip TEXT NOT NULL DEFAULT '', |
| 15 | + val_ip TEXT NULL, |
16 | 16 | PRIMARY KEY (val_id) |
17 | 17 | ); |
18 | 18 | |
Index: trunk/extensions/Review/Review.php |
— | — | @@ -244,7 +244,8 @@ |
245 | 245 | |
246 | 246 | $fname = 'wfReviewExtensionReadLastForm' ; |
247 | 247 | $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 ; |
249 | 250 | |
250 | 251 | # Read form values |
251 | 252 | $oldrev = $wgRequest->getInt ( 'review_oldid' ) ; |
— | — | @@ -311,7 +312,7 @@ |
312 | 313 | |
313 | 314 | # Insert new ratings into the database |
314 | 315 | if ( count ( $new_data ) > 0 ) { |
315 | | - $dbw->begin () ; |
| 316 | + $dbw->begin() ; |
316 | 317 | foreach ( $new_data AS $key => $value ) { |
317 | 318 | $data = array ( |
318 | 319 | 'val_user' => $value->val_user , |
— | — | @@ -322,7 +323,9 @@ |
323 | 324 | 'val_comment' => $value->val_comment , |
324 | 325 | 'val_ip' => $value->val_ip , |
325 | 326 | ) ; |
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 ) ; |
327 | 330 | } |
328 | 331 | $dbw->commit(); |
329 | 332 | } |