[MediaWiki-commits] [Gerrit] mediawiki...UserStatus[master]: Use the PHP wfTimestamp() function instead of the DBMS-speci...

2017-01-17 Thread Legoktm (Code Review)
Legoktm has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/332660 )

Change subject: Use the PHP wfTimestamp() function instead of the DBMS-specific 
UNIX_TIMESTAMP function for converting timestamps
..


Use the PHP wfTimestamp() function instead of the DBMS-specific UNIX_TIMESTAMP 
function for converting timestamps

This'll allow us to eventually support non-MySQL/MariaDB DBMSes properly.

Change-Id: Ic9237e4046f9c815cc9be412f1ec154e72edc0c0
---
M ApiUserStatus.php
M UserStatusClass.php
2 files changed, 8 insertions(+), 10 deletions(-)

Approvals:
  Legoktm: Verified; Looks good to me, approved



diff --git a/ApiUserStatus.php b/ApiUserStatus.php
index dbeb7de..8fb9a58 100644
--- a/ApiUserStatus.php
+++ b/ApiUserStatus.php
@@ -172,8 +172,7 @@
$res = $dbw->select(
'user_status',
array(
-   'us_user_id', 'us_user_name', 'us_text',
-   'UNIX_TIMESTAMP(us_date) AS unix_time'
+   'us_user_id', 'us_user_name', 'us_text', 
'us_date'
),
array( 'us_id' => intval( $next_row ) ),
__METHOD__
@@ -185,7 +184,7 @@
$db_user_id = $row->us_user_id;
$db_user_name = $row->us_user_name;
$db_status_text = $row->us_text;
-   $user_status_date = $row->unix_time;
+   $user_status_date = wfTimestamp( TS_UNIX, $row->us_date 
);
$avatar = new wAvatar( $db_user_id, 'ml' );
$userTitle = Title::makeTitle( NS_USER, $db_user_name );
 
diff --git a/UserStatusClass.php b/UserStatusClass.php
index c8bd483..15a9a99 100644
--- a/UserStatusClass.php
+++ b/UserStatusClass.php
@@ -242,7 +242,7 @@
 
$sql = "SELECT us_id, us_user_id, us_user_name, us_text,
us_sport_id, us_team_id, us_vote_plus, us_vote_minus,
-   UNIX_TIMESTAMP(us_date) AS unix_time,
+   us_date,
(SELECT COUNT(*) FROM {$dbr->tableName( 
'user_status_vote' )}
WHERE sv_us_id = us_id
AND sv_user_id =" . $wgUser->getID() . ") AS 
AlreadyVoted
@@ -256,7 +256,7 @@
foreach ( $res as $row ) {
$messages[] = array(
'id' => $row->us_id,
-   'timestamp' => ($row->unix_time),
+   'timestamp' => wfTimestamp( TS_UNIX, 
$row->us_date ),
'user_id' => $row->us_user_id,
'user_name' => $row->us_user_name,
'sport_id' => $row->us_sport_id,
@@ -316,7 +316,7 @@
 
$sql = "SELECT us_id, us_user_id, us_user_name, us_text,
us_sport_id, us_team_id, us_vote_plus, us_vote_minus,
-   UNIX_TIMESTAMP(us_date) AS unix_time,
+   us_date,
(SELECT COUNT(*) FROM {$dbr->tableName( 
'user_status_vote' )}
WHERE sv_us_id = us_id
AND sv_user_id = " . $wgUser->getID() . ") AS 
AlreadyVoted
@@ -332,7 +332,7 @@
foreach ( $res as $row ) {
$messages[] = array(
'id' => $row->us_id,
-   'timestamp' => ( $row->unix_time ),
+   'timestamp' => wfTimestamp( TS_UNIX, 
$row->us_date ),
'user_id' => $row->us_user_id,
'user_name' => $row->us_user_name,
'sport_id' => $row->us_sport_id,
@@ -501,8 +501,7 @@
$res = $dbr->select(
'user_status_vote',
array(
-   'sv_user_id', 'sv_user_name',
-   'UNIX_TIMESTAMP(sv_date) AS unix_time', 
'sv_vote_score'
+   'sv_user_id', 'sv_user_name', 'sv_date', 
'sv_vote_score'
),
array( 'sv_us_id' => intval( $us_id ) ),
__METHOD__,
@@ -513,7 +512,7 @@
 
foreach ( $res as $row ) {
$voters[] = array(
-   'timestamp' => ( $row->unix_time ),
+   'timestamp' => wfTimestamp( TS_UNIX, 
$row->sv_date ),
'user_id' => $row->sv_user_id,
'user_name' => $row->sv_user_name,
'score' => $row->sv_vote_score

-- 
To view, visit https://gerrit.wikimedia.org/r/332660
To unsubscribe, 

[MediaWiki-commits] [Gerrit] mediawiki...UserStatus[master]: Use the PHP wfTimestamp() function instead of the DBMS-speci...

2017-01-17 Thread Jack Phoenix (Code Review)
Jack Phoenix has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/332660 )

Change subject: Use the PHP wfTimestamp() function instead of the DBMS-specific 
UNIX_TIMESTAMP function for converting timestamps
..

Use the PHP wfTimestamp() function instead of the DBMS-specific UNIX_TIMESTAMP 
function for converting timestamps

This'll allow us to eventually support non-MySQL/MariaDB DBMSes properly.

Change-Id: Ic9237e4046f9c815cc9be412f1ec154e72edc0c0
---
M ApiUserStatus.php
M UserStatusClass.php
2 files changed, 8 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UserStatus 
refs/changes/60/332660/1

diff --git a/ApiUserStatus.php b/ApiUserStatus.php
index dbeb7de..f0d5c54 100644
--- a/ApiUserStatus.php
+++ b/ApiUserStatus.php
@@ -172,8 +172,7 @@
$res = $dbw->select(
'user_status',
array(
-   'us_user_id', 'us_user_name', 'us_text',
-   'UNIX_TIMESTAMP(us_date) AS unix_time'
+   'us_user_id', 'us_user_name', 'us_text', 
'us_date'
),
array( 'us_id' => intval( $next_row ) ),
__METHOD__
@@ -185,7 +184,7 @@
$db_user_id = $row->us_user_id;
$db_user_name = $row->us_user_name;
$db_status_text = $row->us_text;
-   $user_status_date = $row->unix_time;
+   $user_status_date = wfTimestamp( TS_UNIX, 
$row->unix_time );
$avatar = new wAvatar( $db_user_id, 'ml' );
$userTitle = Title::makeTitle( NS_USER, $db_user_name );
 
diff --git a/UserStatusClass.php b/UserStatusClass.php
index c8bd483..15a9a99 100644
--- a/UserStatusClass.php
+++ b/UserStatusClass.php
@@ -242,7 +242,7 @@
 
$sql = "SELECT us_id, us_user_id, us_user_name, us_text,
us_sport_id, us_team_id, us_vote_plus, us_vote_minus,
-   UNIX_TIMESTAMP(us_date) AS unix_time,
+   us_date,
(SELECT COUNT(*) FROM {$dbr->tableName( 
'user_status_vote' )}
WHERE sv_us_id = us_id
AND sv_user_id =" . $wgUser->getID() . ") AS 
AlreadyVoted
@@ -256,7 +256,7 @@
foreach ( $res as $row ) {
$messages[] = array(
'id' => $row->us_id,
-   'timestamp' => ($row->unix_time),
+   'timestamp' => wfTimestamp( TS_UNIX, 
$row->us_date ),
'user_id' => $row->us_user_id,
'user_name' => $row->us_user_name,
'sport_id' => $row->us_sport_id,
@@ -316,7 +316,7 @@
 
$sql = "SELECT us_id, us_user_id, us_user_name, us_text,
us_sport_id, us_team_id, us_vote_plus, us_vote_minus,
-   UNIX_TIMESTAMP(us_date) AS unix_time,
+   us_date,
(SELECT COUNT(*) FROM {$dbr->tableName( 
'user_status_vote' )}
WHERE sv_us_id = us_id
AND sv_user_id = " . $wgUser->getID() . ") AS 
AlreadyVoted
@@ -332,7 +332,7 @@
foreach ( $res as $row ) {
$messages[] = array(
'id' => $row->us_id,
-   'timestamp' => ( $row->unix_time ),
+   'timestamp' => wfTimestamp( TS_UNIX, 
$row->us_date ),
'user_id' => $row->us_user_id,
'user_name' => $row->us_user_name,
'sport_id' => $row->us_sport_id,
@@ -501,8 +501,7 @@
$res = $dbr->select(
'user_status_vote',
array(
-   'sv_user_id', 'sv_user_name',
-   'UNIX_TIMESTAMP(sv_date) AS unix_time', 
'sv_vote_score'
+   'sv_user_id', 'sv_user_name', 'sv_date', 
'sv_vote_score'
),
array( 'sv_us_id' => intval( $us_id ) ),
__METHOD__,
@@ -513,7 +512,7 @@
 
foreach ( $res as $row ) {
$voters[] = array(
-   'timestamp' => ( $row->unix_time ),
+   'timestamp' => wfTimestamp( TS_UNIX, 
$row->sv_date ),
'user_id' => $row->sv_user_id,
'user_name' => $row->sv_user_name,
'score' => $row->sv_vote_score

-- 
To view, visit