Yaron Koren has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/371490 )

Change subject: Fix for DateTime handling in MSSQL - patch by TomyLee
......................................................................


Fix for DateTime handling in MSSQL - patch by TomyLee

Change-Id: Iac98635d06fc1d05246f5b1116873b5c1923fa3b
---
M ED_Utils.php
1 file changed, 6 insertions(+), 2 deletions(-)

Approvals:
  Yaron Koren: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ED_Utils.php b/ED_Utils.php
index e2176e3..ac1fd73 100644
--- a/ED_Utils.php
+++ b/ED_Utils.php
@@ -505,17 +505,21 @@
 
                $rows = array();
                while ( $row = $db->fetchRow( $result ) ) {
-                       // Create a new row object, that uses the passed-in
+                       // Create a new row object that uses the passed-in
                        // column names as keys, so that there's always an
                        // exact match between what's in the query and what's
                        // in the return value (so that "a.b", for instance,
                        // doesn't get chopped off to just "b").
                        $new_row = array();
                        foreach ( $vars as $i => $column_name ) {
+                               $dbField = $row[$i];
+                               // This can happen with MSSQL.
+                               if ( $dbField instanceof DateTime ) {
+                                       $dbField = $dbField->format('Y-m-d 
H:i:s');
+                               }
                                // Convert the encoding to UTF-8
                                // if necessary - based on code at
                                // 
http://www.php.net/manual/en/function.mb-detect-encoding.php#102510
-                               $dbField = $row[$i];
                                if ( !function_exists( 'mb_detect_encoding' ) ||
                                        mb_detect_encoding( $dbField, 'UTF-8', 
true ) == 'UTF-8' ) {
                                        $new_row[$column_name] = $dbField;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iac98635d06fc1d05246f5b1116873b5c1923fa3b
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/ExternalData
Gerrit-Branch: master
Gerrit-Owner: Yaron Koren <yaro...@gmail.com>
Gerrit-Reviewer: Yaron Koren <yaro...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to