r94463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94462‎ | r94463 | r94464 >
Date:15:28, 14 August 2011
Author:zhenya
Status:ok
Tags:
Comment:
likeCount changet to getLikeCount.
num_rows() changet to COUNT(*)
Modified paths:
  • /trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php
@@ -46,7 +46,7 @@
4747 foreach ( $historyArray as $row ) {
4848 $us = htmlspecialchars( $row['ush_status'] );
4949 $status_id = intval( $row['ush_id'] );
50 - $status_likes = $us_class->likeCount( $status_id );
 50+ $status_likes = $us_class->getLikeCount( $status_id );
5151 $href = '';
5252 // We can only *view* other user's past status updates, we cannot
5353 // do anything with them...so don't bother generating the href
Index: trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php
@@ -183,16 +183,15 @@
184184 return;
185185 }
186186
187 - public function likeCount( $status_id ) {
 187+ public function getLikeCount( $status_id ) {
188188 $dbr = wfGetDB( DB_SLAVE );
189 - $statusLikes = $dbr->select(
190 - 'user_status_likes',
191 - '*',
192 - array( 'usl_status_id' => $status_id ),
193 - __METHOD__
194 - );
195 -
196 - return $dbr->numRows( $statusLikes );
 189+ $count = (int)$dbr->selectField(
 190+ 'user_status_likes',
 191+ 'COUNT(*) AS count',
 192+ array( 'usl_status_id' => $status_id ),
 193+ __METHOD__
 194+ );
 195+ return $count;
197196 }
198197
199198 public function likeStatus( $liker_id, $status_id ) {
@@ -219,6 +218,6 @@
220219 __METHOD__
221220 );
222221 }
223 - return (string)$this->likeCount($status_id).' ♥';
 222+ return (string)$this->getLikeCount($status_id).' ♥';
224223 }
225224 }
\ No newline at end of file

Status & tagging log