r57040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57039‎ | r57040 | r57041 >
Date:00:19, 29 September 2009
Author:nimishg
Status:resolved
Tags:
Comment:
MySQL 4.0 compatible now
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php
@@ -29,18 +29,20 @@
3030 global $wgUser;
3131 $today = gmdate( 'Ymd', time() );
3232 $dbw = wfGetDB( DB_MASTER );
33 - /*
34 - //there seems no way to set contribs to contribs+1 in a reasonably fast manner in this framework
35 - try{
36 - $dbw->insert("user_daily_contribs", array("user_id" => $wgUser->getId(), "day" => $today, "contribs" => 1), __METHOD__);
 33+
 34+ //writes only return true/false and an update on 0 rows is true, so try insert, on fail, update
 35+ try
 36+ {
 37+ $dbw->insert("user_daily_contribs", array("user_id" => $wgUser->getId(), "day" => $today, "contribs" => 1), __METHOD__);
3738 }
38 - catch(Exception $e){
39 - $dbw->update( "user_daily_contribs", array( "contribs" => "contribs+1"), array("user_id" => $wgUser->getId(), "day" => $today), __METHOD__);
 39+ catch(Exception $e)
 40+ {
 41+ //normal $db->update doesn't support SQL variables yet
 42+ $sql = "UPDATE user_daily_contribs SET contribs=contribs+1 WHERE day = $today AND user_id = {$wgUser->getId()}";
 43+ $dbw->query($sql, __METHOD__);
4044 }
41 - */
42 - $sql =
43 - "INSERT INTO user_daily_contribs (user_id,day,contribs) VALUES ({$wgUser->getId()},$today,1) ON DUPLICATE KEY UPDATE contribs=contribs+1;";
44 - $dbw->query($sql, __METHOD__);
 45+
 46+
4547 return true;
4648 }
4749

Follow-up revisions

RevisionCommit summaryAuthorDate
r57066Merge r57040 & r57041 mysql 4 compat fixes from trunkbrion17:53, 29 September 2009

Status & tagging log