]> granicus.if.org Git - php/commitdiff
Fix for bug #52115 mysqli_result::fetch_all returns null, not an empty array
authorAndrey Hristov <andrey@php.net>
Fri, 18 Jun 2010 17:25:41 +0000 (17:25 +0000)
committerAndrey Hristov <andrey@php.net>
Fri, 18 Jun 2010 17:25:41 +0000 (17:25 +0000)
NEWS
ext/mysqli/tests/mysqli_fetch_all.phpt
ext/mysqlnd/mysqlnd_result.c

diff --git a/NEWS b/NEWS
index 2ea4eb504a9bafc1c88ac4a03647a733999d51cf..72595129cd710848410f5a71513bb2975110d104 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2010, PHP 5.3.3 RC2
 - Fixed the mail.log ini setting when no filename was given. (Johannes)
+- Fixed bug #52115 (mysqli_result::fetch_all returns null, not an empty array).
+  (Andrey)
 
 17 Jun 2010, PHP 5.3.3 RC1
 - Upgraded bundled sqlite to version 3.6.23.1. (Ilia)
index 122f8cd8f15b203f1368e3b0f8f3a650b4a64e07..63b6ad28486ea3b009b596561cba0abd595b961b 100644 (file)
@@ -383,7 +383,8 @@ array(2) {
   }
 }
 [011]
-NULL
+array(0) {
+}
 [013]
 array(2) {
   [0]=>
@@ -402,7 +403,8 @@ array(2) {
   }
 }
 [016]
-NULL
+array(0) {
+}
 [017]
 array(1) {
   [0]=>
index 7769018d51548c724c17f381100694c0c000ce1d..539cfbce2d663f58e3c2c3bd41ced585f31b0c96 100644 (file)
@@ -1568,16 +1568,17 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, unsigned int flags,
        DBG_INF_FMT("flags=%u", flags);
 
        /* mysqlnd_res::fetch_all works with buffered resultsets only */
-       if (!set ||
-               !set->row_count || !set->data_cursor ||
-               set->data_cursor >= set->data + set->row_count)
-       {
+       if (result->unbuf || (!result->unbuf && !set)) {
                RETVAL_NULL();
                DBG_VOID_RETURN;
-       }       
+       }
 
        mysqlnd_array_init(return_value, (unsigned int) set->row_count);
 
+       if (!set->row_count || !set->data_cursor || set->data_cursor >= set->data + set->row_count) {
+               DBG_VOID_RETURN;
+       }       
+
        while (set->data_cursor &&
                   (set->data_cursor - set->data) < (set->row_count * result->meta->field_count))
        {