r45970 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45969‎ | r45970 | r45971 >
Date:19:55, 21 January 2009
Author:werdna
Status:deferred
Tags:
Comment:
Fix weird problem where the REPLACE would get false positives on INSERT -- inserting 0 instead of NULL into fields.
Use an INSERT IGNORE for extrar safety.
Modified paths:
  • /branches/change-tagging/phase3/includes/ChangeTags.php (modified) (history)

Diff [purge]

Index: branches/change-tagging/phase3/includes/ChangeTags.php
@@ -68,11 +68,11 @@
6969
7070 // Insert the tags rows.
7171 $tagsRows = array();
72 - foreach( $tags as $tag ) {
73 - $tagsRows[] = array( 'ct_tag' => $tag, 'ct_rc_id' => $rc_id, 'ct_log_id' => $log_id, 'ct_rev_id' => $rev_id, 'ct_params' => $params );
 72+ foreach( $tags as $tag ) { // Filter so we don't insert NULLs as zero accidentally.
 73+ $tagsRows[] = array_filter( array( 'ct_tag' => $tag, 'ct_rc_id' => $rc_id, 'ct_log_id' => $log_id, 'ct_rev_id' => $rev_id, 'ct_params' => $params ) );
7474 }
7575
76 - $dbw->replace( 'change_tag', array( array( 'ct_tag', 'ct_rc_id', 'ct_rev_id', 'ct_log_id' ) ), $tagsRows, __METHOD__ );
 76+ $dbw->insert( 'change_tag', array( array( 'ct_tag', 'ct_rc_id', 'ct_rev_id', 'ct_log_id' ) ), $tagsRows, __METHOD__, array('IGNORE') );
7777
7878 return true;
7979 }
@@ -111,7 +111,7 @@
112112 // Add an INNER JOIN on change_tag
113113
114114 $tables[] = 'change_tag';
115 - $join_conds['change_tag'] = array( 'RIGHT JOIN', "ct_$join_cond=$join_cond" );
 115+ $join_conds['change_tag'] = array( 'INNER JOIN', "ct_$join_cond=$join_cond" );
116116 $conds['ct_tag'] = $filter_tag;
117117 }
118118 }

Status & tagging log