From 9d001bbccc1b3784f183cf77641abb2cde56b3e3 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Sun, 14 Jul 2019 21:31:21 +0200 Subject: [PATCH 1/4] Convert E_STRICT into E_NOTICE in mysqli extension --- ext/mysqli/mysqli_api.c | 4 ++-- ext/mysqli/tests/bug31668.phpt | 6 ++++-- ext/mysqli/tests/mysqli_more_results.phpt | 4 ++-- ext/mysqli/tests/mysqli_multi_query.phpt | 4 ++-- ext/mysqli/tests/mysqli_next_result.phpt | 10 +++++----- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index 96cad0dc5ffcd..fe965cbc5620a 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1606,7 +1606,7 @@ PHP_FUNCTION(mysqli_next_result) { MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); if (!mysql_more_results(mysql->mysql)) { - php_error_docref(NULL, E_STRICT, "There is no next result set. " + php_error_docref(NULL, E_NOTICE, "There is no next result set. " "Please, call mysqli_more_results()/mysqli::more_results() to check " "whether to call this function/method"); } @@ -1644,7 +1644,7 @@ PHP_FUNCTION(mysqli_stmt_next_result) { MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); if (!mysqlnd_stmt_more_results(stmt->stmt)) { - php_error_docref(NULL, E_STRICT, "There is no next result set. " + php_error_docref(NULL, E_NOTICE, "There is no next result set. " "Please, call mysqli_stmt_more_results()/mysqli_stmt::more_results() to check " "whether to call this function/method"); } diff --git a/ext/mysqli/tests/bug31668.phpt b/ext/mysqli/tests/bug31668.phpt index 9b769a1bae2f4..2e99b86050ade 100644 --- a/ext/mysqli/tests/bug31668.phpt +++ b/ext/mysqli/tests/bug31668.phpt @@ -5,8 +5,6 @@ Bug #31668 (multi_query works exactly every other time (multi_query was global, require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> ---INI-- -error_reporting = E_ALL & ~E_STRICT --FILE-- %s(1) "2" } + +Notice: mysqli::next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %sbug31668.php on line %d %s(0) "" int(%d) array(1) { @@ -57,5 +57,7 @@ array(1) { [2]=> %s(1) "2" } + +Notice: mysqli::next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %sbug31668.php on line %d %s(0) "" int(%d) diff --git a/ext/mysqli/tests/mysqli_more_results.phpt b/ext/mysqli/tests/mysqli_more_results.phpt index 4ce6a19c79284..553cbdb641612 100644 --- a/ext/mysqli/tests/mysqli_more_results.phpt +++ b/ext/mysqli/tests/mysqli_more_results.phpt @@ -74,12 +74,12 @@ bool(false) 1 2 -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d [010] 1 2 -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d bool(false) diff --git a/ext/mysqli/tests/mysqli_multi_query.phpt b/ext/mysqli/tests/mysqli_multi_query.phpt index 28898b1dcb05a..e78678af0bc09 100644 --- a/ext/mysqli/tests/mysqli_multi_query.phpt +++ b/ext/mysqli/tests/mysqli_multi_query.phpt @@ -120,12 +120,12 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d [006] 3 [008] 0 [009] [2014] Commands out of sync; you can't run this command now -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d [010] 7 Warning: mysqli_multi_query(): Couldn't fetch mysqli in %s on line %d diff --git a/ext/mysqli/tests/mysqli_next_result.phpt b/ext/mysqli/tests/mysqli_next_result.phpt index e01f507c20f73..81a4330e3ca0f 100644 --- a/ext/mysqli/tests/mysqli_next_result.phpt +++ b/ext/mysqli/tests/mysqli_next_result.phpt @@ -73,15 +73,15 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d -Strict Standards: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d +Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d bool(false) From 3cea02c18caa6179446ee2b039a65ac5b1ac8aca Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 15 Jul 2019 14:48:57 +0200 Subject: [PATCH 2/4] Remove notice --- ext/mysqli/mysqli_api.c | 12 ------------ ext/mysqli/tests/bug31668.phpt | 4 ---- ext/mysqli/tests/mysqli_more_results.phpt | 4 ---- ext/mysqli/tests/mysqli_multi_query.phpt | 3 --- ext/mysqli/tests/mysqli_next_result.phpt | 9 --------- 5 files changed, 32 deletions(-) diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index fe965cbc5620a..ffbb841c191f6 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1605,12 +1605,6 @@ PHP_FUNCTION(mysqli_next_result) { } MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID); - if (!mysql_more_results(mysql->mysql)) { - php_error_docref(NULL, E_NOTICE, "There is no next result set. " - "Please, call mysqli_more_results()/mysqli::more_results() to check " - "whether to call this function/method"); - } - RETURN_BOOL(!mysql_next_result(mysql->mysql)); } /* }}} */ @@ -1643,12 +1637,6 @@ PHP_FUNCTION(mysqli_stmt_next_result) { } MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); - if (!mysqlnd_stmt_more_results(stmt->stmt)) { - php_error_docref(NULL, E_NOTICE, "There is no next result set. " - "Please, call mysqli_stmt_more_results()/mysqli_stmt::more_results() to check " - "whether to call this function/method"); - } - RETURN_BOOL(!mysql_stmt_next_result(stmt->stmt)); } /* }}} */ diff --git a/ext/mysqli/tests/bug31668.phpt b/ext/mysqli/tests/bug31668.phpt index 2e99b86050ade..40bf357b6aa6e 100644 --- a/ext/mysqli/tests/bug31668.phpt +++ b/ext/mysqli/tests/bug31668.phpt @@ -45,8 +45,6 @@ array(1) { [2]=> %s(1) "2" } - -Notice: mysqli::next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %sbug31668.php on line %d %s(0) "" int(%d) array(1) { @@ -57,7 +55,5 @@ array(1) { [2]=> %s(1) "2" } - -Notice: mysqli::next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %sbug31668.php on line %d %s(0) "" int(%d) diff --git a/ext/mysqli/tests/mysqli_more_results.phpt b/ext/mysqli/tests/mysqli_more_results.phpt index 553cbdb641612..7f0a1f748b09b 100644 --- a/ext/mysqli/tests/mysqli_more_results.phpt +++ b/ext/mysqli/tests/mysqli_more_results.phpt @@ -73,14 +73,10 @@ bool(false) [006] 1 2 - -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d [010] 1 2 -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d - Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d bool(false) done! diff --git a/ext/mysqli/tests/mysqli_multi_query.phpt b/ext/mysqli/tests/mysqli_multi_query.phpt index e78678af0bc09..8fa67e17a4d61 100644 --- a/ext/mysqli/tests/mysqli_multi_query.phpt +++ b/ext/mysqli/tests/mysqli_multi_query.phpt @@ -120,12 +120,9 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d [006] 3 [008] 0 [009] [2014] Commands out of sync; you can't run this command now - -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d [010] 7 Warning: mysqli_multi_query(): Couldn't fetch mysqli in %s on line %d diff --git a/ext/mysqli/tests/mysqli_next_result.phpt b/ext/mysqli/tests/mysqli_next_result.phpt index 81a4330e3ca0f..6760cbbadc596 100644 --- a/ext/mysqli/tests/mysqli_next_result.phpt +++ b/ext/mysqli/tests/mysqli_next_result.phpt @@ -73,15 +73,6 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d - -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d - -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d - -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d - -Notice: mysqli_next_result(): There is no next result set. Please, call mysqli_more_results()/mysqli::more_results() to check whether to call this function/method in %s on line %d Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d bool(false) From 43404b848a4ad46cb6e178c74ff823153d481da8 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Mon, 15 Jul 2019 19:12:49 +0200 Subject: [PATCH 3/4] Add test for graceful fail on empty result set --- .../gracefull_fail_on_empty_result_set.phpt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt diff --git a/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt b/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt new file mode 100644 index 0000000000000..e37e22887a86b --- /dev/null +++ b/ext/mysqli/tests/gracefull_fail_on_empty_result_set.phpt @@ -0,0 +1,59 @@ +--TEST-- +Fail gracefully on empty result set +--SKIPIF-- + +--FILE-- +multi_query("SELECT 1"); + var_dump($link->next_result()); // should return false + var_dump($link->store_result()); // now what happens here!? + + + // Returns only one result set + $link->multi_query("SELECT 1"); + var_dump($link->next_result()); + var_dump($link->use_result()); + + $link->close(); +?> +=== DONE === +--CLEAN-- + +--EXPECT-- +bool(false) +object(mysqli_result)#3 (5) { + ["current_field"]=> + int(0) + ["field_count"]=> + int(1) + ["lengths"]=> + NULL + ["num_rows"]=> + int(1) + ["type"]=> + int(0) +} +bool(false) +object(mysqli_result)#3 (5) { + ["current_field"]=> + int(0) + ["field_count"]=> + int(1) + ["lengths"]=> + NULL + ["num_rows"]=> + int(0) + ["type"]=> + int(1) +} +=== DONE === From 3067187f54d55b248105b7ea9f903ae7ee130ce6 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 19 Jul 2019 15:05:17 +0200 Subject: [PATCH 4/4] Remove now unnecessary @ operator --- ext/mysqli/tests/mysqli_multi_query.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/mysqli/tests/mysqli_multi_query.phpt b/ext/mysqli/tests/mysqli_multi_query.phpt index 8fa67e17a4d61..05f564313d757 100644 --- a/ext/mysqli/tests/mysqli_multi_query.phpt +++ b/ext/mysqli/tests/mysqli_multi_query.phpt @@ -104,7 +104,7 @@ require_once('skipifconnectfailure.inc'); mysqli_free_result($res); - } while (@mysqli_next_result($link)); + } while (mysqli_next_result($link)); if ($res_num != 4) printf("[015] Expecting 3 result sets got %d result set[s]\n", $res_num);