r91244 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91243‎ | r91244 | r91245 >
Date:01:55, 1 July 2011
Author:demon
Status:ok
Tags:
Comment:
Fix for r84932: explicit checking for null isn't necessary
Also use $user in ArticleSaveComplete hook rather than relying on $wgUser
Modified paths:
  • /trunk/extensions/UserDailyContribs/UserDailyContribs.hooks.php (modified) (history)
  • /trunk/extensions/UserDailyContribs/api/ApiUserDailyContribs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UserDailyContribs/api/ApiUserDailyContribs.php
@@ -18,7 +18,7 @@
1919 'id', $user->getId() );
2020 // returns date of registration in YYYYMMDDHHMMSS format
2121 $result->addValue( $this->getModuleName() ,
22 - 'registration', ($user->getRegistration() == NULL)?'0':$user->getRegistration() );
 22+ 'registration', $user->getRegistration() ? '0' : $user->getRegistration() );
2323 // returns number of edits since daysago param
2424 $result->addValue( $this->getModuleName() ,
2525 'timeFrameEdits', getUserEditCountSince( $now - ($days * 60 *60 *24), $user ) );
Index: trunk/extensions/UserDailyContribs/UserDailyContribs.hooks.php
@@ -42,21 +42,19 @@
4343 *
4444 * @return true
4545 */
46 - public static function articleSaveComplete(){
47 - global $wgUser;
48 -
 46+ public static function articleSaveComplete( $article, $user ){
4947 $today = gmdate( 'Ymd', time() );
5048 $dbw = wfGetDB( DB_MASTER );
5149 $dbw->update(
5250 'user_daily_contribs',
5351 array( 'contribs=contribs+1' ),
54 - array( 'day' => $today, 'user_id' => $wgUser->getId() ),
 52+ array( 'day' => $today, 'user_id' => $user->getId() ),
5553 __METHOD__
5654 );
5755 if ( $dbw->affectedRows() == 0 ){
5856 $dbw->insert(
5957 'user_daily_contribs',
60 - array( 'user_id' => $wgUser->getId(), 'day' => $today, 'contribs' => 1 ),
 58+ array( 'user_id' => $user->getId(), 'day' => $today, 'contribs' => 1 ),
6159 __METHOD__
6260 );
6361 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r105267[HarvardResearch] Swap ternary operator in registration fallback to zero...krinkle01:02, 6 December 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84932handles null registrationnimishg22:15, 28 March 2011

Status & tagging log