r86662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86661‎ | r86662 | r86663 >
Date:20:22, 21 April 2011
Author:nimishg
Status:resolved (Comments)
Tags:
Comment:
bugfixes
Modified paths:
  • /trunk/extensions/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/ClickTracking/modules/ext.UserBuckets.js (modified) (history)
  • /trunk/extensions/ClickTracking/patches/ClickTrackingUserProperties.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/ClickTracking.hooks.php
@@ -209,12 +209,9 @@
210210 $db_status = $dbw->insert( 'click_tracking', $data, __METHOD__ );
211211 $dbw->commit();
212212
213 -
214 -
215 -
216213 if( $recordBucketInfo && $db_status ){
217214 $buckets = self::unpackBucketInfo();
218 -
 215+ $dbw->ignoreErrors( true ); // if inserting on duplicate key, it's ok
219216 if( $buckets ){
220217 foreach( $buckets as $bucketName => $bucketValue ){
221218 $db_current_bucket_insert = $dbw->insert( 'click_tracking_user_properties',
@@ -228,9 +225,9 @@
229226 $db_status_buckets = $db_status_buckets && $db_current_bucket_insert;
230227 }
231228 }//ifbuckets
 229+ $dbw->ignoreErrors( false );
232230 }//ifrecord
233231
234 -
235232 $dbw->commit();
236233 return ($db_status && $db_status_buckets);
237234
Index: trunk/extensions/ClickTracking/patches/ClickTrackingUserProperties.sql
@@ -14,10 +14,10 @@
1515 property_value varbinary(255),
1616
1717 -- property version
18 - property_version INTEGER,
 18+ property_version INTEGER
1919
20 - UNIQUE KEY id_name_value_version (session_id, property_name, property_value, property_version)
21 -
2220 ) /*$wgDBTableOptions*/;
2321
24 -CREATE INDEX /*i*/click_tracking_user_properties_session_idx ON /*_*/click_tracking_user_properties (session_id);
\ No newline at end of file
 22+CREATE INDEX /*i*/click_tracking_user_properties_session_idx ON /*_*/click_tracking_user_properties (session_id);
 23+
 24+CREATE UNIQUE INDEX ct_user_prop_id_name_value_version ON /*_*/click_tracking_user_properties(session_id, property_name, property_value, property_version);
\ No newline at end of file
Index: trunk/extensions/ClickTracking/modules/ext.UserBuckets.js
@@ -40,9 +40,7 @@
4141
4242 $.setBucket = function ( bucketName, bucketValue, bucketVersion ){
4343 var bucketCookies = $.getBuckets();
44 - alert("HELLOA");
4544 if(!bucketCookies) { bucketCookies ={};}
46 - alert("HELLOB");
4745 bucketCookies[ bucketName ] = [ bucketValue, bucketVersion ];
4846 $j.cookie('userbuckets', JSON.stringify( bucketCookies ) , { expires: 365 }); //expires in 1 year
4947 bucketCookies = $.getBuckets(true); //force it to rerun and update

Comments

#Comment by Reedy (talk | contribs)   20:56, 21 April 2011

You realise you can just do INSERT IGNORE? Rather than suppressing all errors?

#Comment by Nimish Gautam (talk | contribs)   21:12, 21 April 2011

I didn't see a way to do that with the DB object other than straight sql

#Comment by Happy-melon (talk | contribs)   21:13, 21 April 2011

It's the $options parameter to $db->select(), IIRC.

#Comment by Reedy (talk | contribs)   21:34, 21 April 2011
		$dbw->insert(
			'article_feedback_pages',
			 array(
				'aap_page_id' => $pageId,
				'aap_total' => 0,
				'aap_count' => 0,
				'aap_rating_id' => $ratingId,
			),
			__METHOD__,
			 array( 'IGNORE' )
		);
#Comment by Nimish Gautam (talk | contribs)   23:40, 21 April 2011

fixed in r86684

Status & tagging log