r86578 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86577‎ | r86578 | r86579 >
Date:00:01, 21 April 2011
Author:nimishg
Status:resolved (Comments)
Tags:
Comment:
fixed bug that namespace wasn't accurately being recorded, no more duplicate entries on user properties table, fixed errors on userbuckets
Modified paths:
  • /trunk/extensions/ClickTracking/ApiClickTracking.php (modified) (history)
  • /trunk/extensions/ClickTracking/modules/ext.UserBuckets.js (modified) (history)
  • /trunk/extensions/ClickTracking/modules/jquery.clickTracking.js (modified) (history)
  • /trunk/extensions/ClickTracking/patches/ClickTrackingUserProperties.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/patches/ClickTrackingUserProperties.sql
@@ -14,7 +14,10 @@
1515 property_value varbinary(255),
1616
1717 -- property version
18 - property_version INTEGER
 18+ property_version INTEGER,
 19+
 20+ UNIQUE KEY id_name_value_version (session_id, property_name, property_value, property_version)
 21+
1922 ) /*$wgDBTableOptions*/;
2023
2124 CREATE INDEX /*i*/click_tracking_user_properties_session_idx ON /*_*/click_tracking_user_properties (session_id);
\ No newline at end of file
Index: trunk/extensions/ClickTracking/ApiClickTracking.php
@@ -25,7 +25,8 @@
2626 $this->validateParams( $params );
2727 $eventid_to_lookup = $params['eventid'];
2828 $sessionId = $params['token'];
29 -
 29+ $namespace = $params['namespacenumber'];
 30+
3031 $additional = null;
3132
3233 if ( isset( $params['additional'] ) && strlen( $params['additional'] ) > 0 ) {
@@ -50,7 +51,7 @@
5152 ClickTrackingHooks::trackEvent(
5253 $sessionId, // randomly generated session ID
5354 $isLoggedIn, // is the user logged in?
54 - $wgTitle->getNamespace(), // what namespace are they editing?
 55+ (int)$namespace, // what namespace are they editing?
5556 $eventId, // event ID passed in
5657 ( $isLoggedIn ? $wgUser->getEditCount() : 0 ), // total edit count or 0 if anonymous
5758 $granularity1, // contributions made in granularity 1 time frame
@@ -85,7 +86,7 @@
8687 * @param $params params extracted from the POST
8788 */
8889 protected function validateParams( $params ) {
89 - $required = array( 'eventid', 'token' );
 90+ $required = array( 'eventid', 'token', 'namespacenumber' );
9091 foreach ( $required as $arg ) {
9192 if ( !isset( $params[$arg] ) ) {
9293 $this->dieUsageMsg( array( 'missingparam', $arg ) );
@@ -97,6 +98,7 @@
9899 return array(
99100 'eventid' => 'string of eventID',
100101 'token' => 'unique edit ID for this edit session',
 102+ 'namespacenumber' => 'the namespace number being edited',
101103 'redirectto' => 'URL to redirect to (only used for links that go off the page)',
102104 'additional' => 'additional info for the event, like state information'
103105 );
@@ -112,12 +114,14 @@
113115 return array_merge( parent::getPossibleErrors(), array(
114116 array( 'missingparam', 'eventid' ),
115117 array( 'missingparam', 'token' ),
 118+ array( 'missingparam', 'namespacenumber'),
116119 ) );
117120 }
118121
119122 public function getAllowedParams() {
120123 return array(
121124 'eventid' => null,
 125+ 'namespacenumber' => null,
122126 'token' => null,
123127 'redirectto' => null,
124128 'additional' => null
Index: trunk/extensions/ClickTracking/modules/jquery.clickTracking.js
@@ -28,6 +28,7 @@
2929 $.post(
3030 mediaWiki.config.get( 'wgScriptPath' ) + '/api.php', {
3131 'action': 'clicktracking',
 32+ 'namespacenumber': mediaWiki.config.get( 'wgNamespaceNumber' ),
3233 'eventid': id,
3334 'token': $.cookie( 'clicktracking-session' )
3435 }
@@ -44,6 +45,7 @@
4546 mediaWiki.config.get( 'wgScriptPath' ) + '/api.php', {
4647 'action': 'clicktracking',
4748 'eventid': id,
 49+ 'namespacenumber': mediaWiki.config.get( 'wgNamespaceNumber' ),
4850 'token': $.cookie( 'clicktracking-session' ),
4951 'additional': info
5052 }
@@ -60,6 +62,7 @@
6163 return mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
6264 'action': 'clicktracking',
6365 'eventid': id,
 66+ 'namespacenumber': mediaWiki.config.get( 'wgNamespaceNumber' ),
6467 'token': $.cookie( 'clicktracking-session' ),
6568 'redirectto': url
6669 } );
Index: trunk/extensions/ClickTracking/modules/ext.UserBuckets.js
@@ -40,7 +40,9 @@
4141
4242 $.setBucket = function ( bucketName, bucketValue, bucketVersion ){
4343 var bucketCookies = $.getBuckets();
 44+ alert("HELLOA");
4445 if(!bucketCookies) { bucketCookies ={};}
 46+ alert("HELLOB");
4547 bucketCookies[ bucketName ] = [ bucketValue, bucketVersion ];
4648 $j.cookie('userbuckets', JSON.stringify( bucketCookies ) , { expires: 365 }); //expires in 1 year
4749 bucketCookies = $.getBuckets(true); //force it to rerun and update
@@ -77,7 +79,7 @@
7880 }
7981
8082 // do the actual code in the campaign based on the bucket
81 - if($.getBuckets()[campaign.name] && $.getBuckets()[campaign.name][0] != "none"){
 83+ if($.getBuckets() && $.getBuckets()[campaign.name] && $.getBuckets()[campaign.name][0] != "none"){
8284 campaign[$.getBuckets()[campaign.name][0]](); //function to execute
8385 if(campaign.allActive){
8486 campaign.allActive();

Comments

#Comment by Catrope (talk | contribs)   08:35, 21 April 2011
+	UNIQUE KEY id_name_value_version (session_id, property_name, property_value, property_version)

This won't work on SQLite AFAIK. Use a CREATE UNIQUE INDEX statement below the table definition, the way the other indices are added.

+	alert("HELLOA");
 	if(!bucketCookies) { bucketCookies ={};}
+	alert("HELLOB");

Debugging code.

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

fixed in r86662

Status & tagging log