From: Andrey Hristov Date: Mon, 9 Aug 2010 17:29:30 +0000 (+0000) Subject: Fix Request #52302 mysqli_fetch_all does not work with MYSQLI_USE_RESULT X-Git-Tag: php-5.3.4RC1~377 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d3d29263302866ff14641790926c06abfe7c0e3;p=php Fix Request #52302 mysqli_fetch_all does not work with MYSQLI_USE_RESULT --- diff --git a/NEWS b/NEWS index ba86a50823..cc819be5a6 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ PHP NEWS empty). (Felipe) - Fixed bug #52436 (Compile error if systems do not have stdint.h) (Sriram Natarajan) +- Fixed bug #52302 (mysqli_fetch_all does not work with MYSQLI_USE_RESULT). + (Andrey). - Fixed bug #51610 (Using oci_connect causes PHP to take a long time to exit). Requires Oracle bug fix 9891199 for this patch to have an effect. (Oracle Corp.) diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 4de2f39ee3..e4a15478d3 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -1567,8 +1567,7 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, unsigned int flags, DBG_ENTER("mysqlnd_res::fetch_all"); DBG_INF_FMT("flags=%u", flags); - /* mysqlnd_res::fetch_all works with buffered resultsets only */ - if (result->unbuf || (!result->unbuf && !set)) { + if ((!result->unbuf && !set)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "fetch_all can be used only with buffered sets"); if (result->conn) { SET_CLIENT_ERROR(result->conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "fetch_all can be used only with buffered sets"); @@ -1577,19 +1576,17 @@ MYSQLND_METHOD(mysqlnd_res, fetch_all)(MYSQLND_RES * result, unsigned int flags, DBG_VOID_RETURN; } - mysqlnd_array_init(return_value, (unsigned int) set->row_count); + mysqlnd_array_init(return_value, (unsigned int) set? set->row_count : 4); /* 4 is a magic value */ - 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)) - { + do { MAKE_STD_ZVAL(row); mysqlnd_fetch_into(result, flags, row, MYSQLND_MYSQLI); + if (Z_TYPE_P(row) != IS_ARRAY) { + zval_ptr_dtor(&row); + break; + } add_index_zval(return_value, i++, row); - } + } while (1); DBG_VOID_RETURN; }