r92147 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92146‎ | r92147 | r92148 >
Date:10:42, 14 July 2011
Author:zhenya
Status:resolved (Comments)
Tags:
Comment:
*small fix in sql;
*changed date/time format in history;
*check for Blocked users and wfReadOnly
Modified paths:
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus.css (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStatus/userstatus.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserStatus/userstatus.sql
@@ -1,12 +1,10 @@
22 CREATE TABLE /*_*/user_status (
33 -- Unique status ID number
4 - `us_id` int(11) NOT NULL DEFAULT 0 PRIMARY KEY,
 4+ `us_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
55 -- ID number of the user who wrote this status update
66 `us_user_id` int(11) NOT NULL default '0',
77 -- Timestamp of the status update
88 `us_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
9 - -- Name of the person who wrote the status update
10 - `us_user_text` varchar(255) NOT NULL default '',
119 -- The text of the status update
1210 `us_status` varchar(140) NOT NULL default ''
1311 )/*$wgDBTableOptions*/;
Index: trunk/extensions/SocialProfile/UserStatus/UserStatus_AjaxFunctions.php
@@ -21,7 +21,9 @@
2222 $historyArray = $us_class->useStatusHistory('select', $u_id);
2323 $output='<table id="user-status-history">';
2424 foreach ($historyArray as $row ) {
25 - $output .= '<tr><td id="status-history-time">'.$row['ush_timestamp'].' </td>';
 25+ $time = DateTime::createFromFormat('Y-m-d H:i:s',$row['ush_timestamp']);
 26+
 27+ $output .= '<tr><td id="status-history-time">'.date_format($time, 'j M G:i').' </td>';
2628 $output .= '<td><a href="javascript:UserStatus.fromHistoryToStatus(\''.$row['ush_status'].'\');">'
2729 .$row['ush_status'].'</a></td></tr>';
2830 }
Index: trunk/extensions/SocialProfile/UserStatus/UserStatus.css
@@ -1,9 +1,3 @@
2 -#status-history-time
3 -{
4 - font-size: 9px;
5 - color: #665;
6 -}
7 -
82 #status-box
93 {
104 width : 400px;
@@ -39,14 +33,26 @@
4034 {
4135 color: white;
4236 font-size: 8pt;
43 - text-decoration: underline
 37+ text-decoration: underline;
4438 }
4539
4640 #user-status-history
4741 {
4842 background-color: orange;
 43+ color: white;
4944 }
5045
 46+#user-status-history a
 47+{
 48+ text-decoration: underline;
 49+ color: white;
 50+}
 51+
 52+#status-history-time
 53+{
 54+ font-size: 9px;
 55+}
 56+
5157 #status-letter-count
5258 {
5359 float:right;
Index: trunk/extensions/SocialProfile/UserStatus/UserStatusClass.php
@@ -45,6 +45,7 @@
4646 * @param $message String: user-supplied status message
4747 */
4848 public function setStatus( $u_id, $message ) {
 49+ $message = trim($message);
4950 if (( mb_strlen( $message ) > 70 ) || ( mb_strlen( $message ) < 1 )) {
5051 // ERROR. Message length is too long
5152 // @todo Communicate failure to the end-user somehow...

Follow-up revisions

RevisionCommit summaryAuthorDate
r92407some small changes in getStatus funczhenya19:29, 17 July 2011

Comments

#Comment by Jack Phoenix (talk | contribs)   20:43, 15 July 2011
-  -- Name of the person who wrote the status update
-  `us_user_text` varchar(255) NOT NULL default '',

Took me a quick grep to make sure that this wasn't used anywhere. I don't think that many core MediaWiki tables have the author's ID number but not a field for their username (i.e the revision table has rev_user field for storing the user's ID number and rev_user_text for storing the user's username).

+			$time = DateTime::createFromFormat('Y-m-d H:i:s',$row['ush_timestamp']);
+		
+            $output .= '<tr><td id="status-history-time">'.date_format($time, 'j M G:i').' </td>';

This feels rather icky to me. Would it be possible to use wfTimestamp() and/or the related Language stuff ($wgLang->dateandttime(), $wgLang->date(), $wgLang->time() and whatnot) here? Most, if not all parts of SocialProfile use stuff like date( 'Y-m-d H:i:s' ) instead of the proper MediaWiki functions, such as wfTimestampNow(), but this is due to historical reasons — SocialProfile wasn't written with non-English sites and non-MySQL backends in mind when it was created. One of these days I'll need to look into migrating all that old stuff to use the proper MediaWiki functions, but that day isn't going to be anytime soon.
That being said, I'd love if new code wouldn't repeat old mistakes. :)

+#user-status-history a
+{

The opening brace should be place on the same line as the selector, i.e. #user-status-history a { as per our coding standards.

Status & tagging log