r102135 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102134‎ | r102135 | r102136 >
Date:00:54, 6 November 2011
Author:ashley
Status:deferred (Comments)
Tags:socialprofile 
Comment:
SocialProfile: as per Markus' in-depth review:
*make the code do what the docs claim it does (default value of $type)
*use DB_SLAVE for read-only access instead of DB_MASTER and rename the handler variable accordingly
Modified paths:
  • /trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserSystemMessages/UserSystemMessagesClass.php
@@ -16,7 +16,7 @@
1717 * @param $type Integer: 0 by default
1818 * @param $message Mixed: message to be sent out
1919 */
20 - public function addMessage( $userName, $type, $message ) {
 20+ public function addMessage( $userName, $type = 0, $message ) {
2121 $userId = User::idFromName( $userName );
2222 $dbw = wfGetDB( DB_MASTER );
2323
@@ -56,7 +56,7 @@
5757 * @return $requests
5858 */
5959 public function getMessageList( $type, $limit = 0, $page = 0 ) {
60 - $dbw = wfGetDB( DB_MASTER );
 60+ $dbr = wfGetDB( DB_SLAVE );
6161
6262 if ( $limit > 0 ) {
6363 $limitvalue = 0;
@@ -68,7 +68,7 @@
6969 }
7070
7171 $params['ORDER BY'] = 'ug_id DESC';
72 - $res = $dbw->select(
 72+ $res = $dbr->select(
7373 array( 'user_gift', 'gift' ),
7474 array(
7575 'ug_id', 'ug_user_id_from', 'ug_user_name_from', 'ug_gift_id',

Comments

#Comment by Nikerabbit (talk | contribs)   09:44, 6 November 2011

Having default values for parameters followed by mandatory parameters isn't that useful.

Status & tagging log