r102178 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102177‎ | r102178 | r102179 >
Date:15:06, 6 November 2011
Author:ashley
Status:ok
Tags:
Comment:
SocialProfile: as per Markus' in-depth review:
*move inline CSS to the CSS file
*remove unused class member variables
*mark UserBoard's constructor as public
*uncomment the part of getNewMessageCountDB() that actually gets the new message count from the database
*use DB_SLAVE for reads
Modified paths:
  • /trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoard.css (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php
@@ -3,18 +3,11 @@
44 * Functions for managing user board data
55 */
66 class UserBoard {
7 - /**#@+
8 - * @private
9 - */
10 - var $user_id;
11 - var $user_name;
127
138 /**
149 * Constructor
15 - * @private
1610 */
17 - /* private */ function __construct() {
18 - }
 11+ public function __construct() {}
1912
2013 /**
2114 * Sends a user board message to another user.
@@ -155,9 +148,6 @@
156149
157150 $key = wfMemcKey( 'user', 'newboardmessage', $user_id );
158151 $newCount = 0;
159 - /* @todo FIXME: why is this commented out? This obviously should be
160 - enabled, because without this, this function is basically identical
161 - to clearNewMessagesCount...
162152 $dbw = wfGetDB( DB_MASTER );
163153 $s = $dbw->selectRow(
164154 'user_board',
@@ -168,7 +158,6 @@
169159 if ( $s !== false ) {
170160 $newCount = $s->count;
171161 }
172 - */
173162
174163 $wgMemc->set( $key, $newCount );
175164
@@ -205,8 +194,8 @@
206195 * @return Boolean: true if user owns the message, otherwise false
207196 */
208197 public function doesUserOwnMessage( $user_id, $ub_id ) {
209 - $dbw = wfGetDB( DB_MASTER );
210 - $s = $dbw->selectRow(
 198+ $dbr = wfGetDB( DB_SLAVE );
 199+ $s = $dbr->selectRow(
211200 'user_board',
212201 array( 'ub_user_id' ),
213202 array( 'ub_id' => $ub_id ),
@@ -391,8 +380,8 @@
392381 <div class=\"user-board-message-from\">
393382 <a href=\"{$user->escapeFullURL()}\" title=\"{$message['user_name_from']}\">{$message['user_name_from']}</a> {$message_type_label}
394383 </div>
395 - <div class=\"user-board-message-time\">"
396 - . wfMsgHtml( 'userboard_posted_ago', $this->getTimeAgo( $message['timestamp'] ) ) .
 384+ <div class=\"user-board-message-time\">" .
 385+ wfMsgHtml( 'userboard_posted_ago', $this->getTimeAgo( $message['timestamp'] ) ) .
397386 "</div>
398387 <div class=\"user-board-message-content\">
399388 <div class=\"user-board-message-image\">
Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php
@@ -144,8 +144,8 @@
145145
146146 if ( $total ) {
147147 $output .= '<div class="user-page-message-top">
148 - <span class="user-page-message-count" style="font-size:11px;color:#666666;">'
149 - . wfMsg( 'userboard_showingmessages', $total, $start, $end, $end - $start + 1 ) .
 148+ <span class="user-page-message-count">' .
 149+ wfMsg( 'userboard_showingmessages', $total, $start, $end, $end - $start + 1 ) .
150150 "</span> {$board_to_board}
151151 </div>";
152152 }
@@ -221,7 +221,7 @@
222222 $output .= '<div class="user-page-message-form">
223223 <input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
224224 <input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
225 - <span style="color:#797979;">' . wfMsg( 'userboard_messagetype' ) . ' </span>
 225+ <span class="user-board-message-type">' . wfMsg( 'userboard_messagetype' ) . ' </span>
226226 <select id="message_type">
227227 <option value="0">' . wfMsg( 'userboard_public' ) . '</option>
228228 <option value="1">' . wfMsg( 'userboard_private' ) . '</option>
@@ -285,7 +285,7 @@
286286 // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
287287 $ub_message_text = $ub_message['message_text'];
288288
289 - $output .= "<div class=\"user-board-message\" style=\"width:550px\">
 289+ $output .= "<div class=\"user-board-message\">
290290 <div class=\"user-board-message-from\">
291291 <a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}
292292 </div>
Index: trunk/extensions/SocialProfile/UserBoard/UserBoard.css
@@ -37,6 +37,7 @@
3838 .user-board-message {
3939 border: 1px solid #D4DFD7;
4040 margin: 0px 0px 15px 0px;
 41+ width: 550px;
4142 }
4243
4344 .user-board-message-from {
@@ -102,3 +103,12 @@
103104 .user-page-message-form textarea {
104105 width: 80%;
105106 }
 107+
 108+.user-page-message-count {
 109+ color: #666666;
 110+ font-size: 11px;
 111+}
 112+
 113+.user-board-message-type {
 114+ color: #797979;
 115+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r104097SocialProfile: partially revert r102178 -- turns out that this code is bad co...ashley22:46, 23 November 2011

Status & tagging log