]> granicus.if.org Git - php/commitdiff
Simplify E_STRICT handling in mysqli tests
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 3 Feb 2018 18:11:55 +0000 (19:11 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 3 Feb 2018 18:11:55 +0000 (19:11 +0100)
E_STRICT is always defined, so we don't need to handle it
conditionally. Instead just let the message be printed and check
the output.

ext/mysqli/tests/mysqli_more_results.phpt
ext/mysqli/tests/mysqli_multi_query.phpt
ext/mysqli/tests/mysqli_next_result.phpt

index 271c63e1d19c60bda730b77c10cf9773aa3370f6..4657c8c2f23f708d0fb88a4ba47e113eb789d131 100644 (file)
@@ -10,12 +10,6 @@ require_once('skipifconnectfailure.inc');
 <?php
        require_once("connect.inc");
 
-       $strict_on = false;
-       if (defined('E_STRICT')) {
-               error_reporting(((int)ini_get('error_reporting')) | E_STRICT );
-               $strict_on = true;
-       }
-
        $tmp    = NULL;
        $link   = NULL;
 
@@ -35,9 +29,6 @@ require_once('skipifconnectfailure.inc');
        print "[006]\n";
        $i = 1;
 
-       if ($strict_on)
-               ob_start();
-
        if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link)))
                printf("[007] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
        do {
@@ -47,17 +38,6 @@ require_once('skipifconnectfailure.inc');
                        printf("%d\n", $i++);
        } while (mysqli_next_result($link));
 
-       if ($strict_on) {
-               $tmp = ob_get_contents();
-               ob_end_clean();
-               if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                       printf("[008] Strict Standards warning missing\n");
-               } else {
-                       $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-               }
-                       print trim($tmp) . "\n";
-       }
-
        if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3"))
                printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        print "[010]\n";
@@ -65,8 +45,6 @@ require_once('skipifconnectfailure.inc');
        if (mysqli_get_server_version($link) > 41000 && !($ret = mysqli_more_results($link)))
                printf("[011] Expecting boolean/true, got %s/%s\n", gettype($ret), $ret);
 
-       if ($strict_on)
-               ob_start();
        do {
                $res = mysqli_use_result($link);
                // NOTE: if you use mysqli_use_result() with mysqli_more_results() or any other info function,
@@ -79,16 +57,6 @@ require_once('skipifconnectfailure.inc');
                        printf("%d\n", $i++);
        } while (mysqli_next_result($link));
 
-       if ($strict_on) {
-               $tmp = ob_get_contents();
-               ob_end_clean();
-               if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                       printf("[008] Strict Standards warning missing\n");
-               } else {
-                       $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-               }
-               print trim($tmp) . "\n";
-       }
        mysqli_close($link);
 
        var_dump(mysqli_more_results($link));
@@ -105,10 +73,14 @@ bool(false)
 [006]
 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
 [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
+
 Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d
 NULL
-done!
\ No newline at end of file
+done!
index 91c07c256432d45574a96a1be14338179074db32..7cc84a0bf983065575731b4552e408e8e51f0d33 100644 (file)
@@ -10,11 +10,6 @@ require_once('skipifconnectfailure.inc');
 <?php
        require_once("connect.inc");
 
-       $strict_on = false;
-       if (defined('E_STRICT')) {
-               error_reporting(((int)ini_get('error_reporting')) | E_STRICT );
-               $strict_on = true;
-       }
        $tmp    = NULL;
        $link   = NULL;
 
@@ -32,9 +27,6 @@ require_once('skipifconnectfailure.inc');
        if (!mysqli_multi_query($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3"))
                printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-       if ($strict_on)
-               ob_start();
-
        $i = 0;
        do {
                $res = mysqli_store_result($link);
@@ -44,17 +36,6 @@ require_once('skipifconnectfailure.inc');
                $i++;
        } while (mysqli_next_result($link));
 
-       if ($strict_on) {
-               $tmp = ob_get_contents();
-               ob_end_clean();
-               if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                       printf("[005a] Strict Standards warning missing\n");
-               } else {
-                       $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-               }
-               print trim($tmp) . "\n";
-       }
-
        printf("[006] %d\n", $i);
 
        if (!mysqli_multi_query($link, "ALTER TABLE test MODIFY id INT AUTO_INCREMENT; INSERT INTO test(label) VALUES ('a'); SELECT id, label FROM test ORDER BY id"))
@@ -74,24 +55,12 @@ require_once('skipifconnectfailure.inc');
        if (!mysqli_multi_query($link, "SELECT id, label FROM test"))
                printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
 
-       if ($strict_on)
-               ob_start();
        $i = 0;
        while (mysqli_next_result($link) && ($res = mysqli_store_result($link))) {
                while ($row = mysqli_fetch_array($res))
                        $i++;
                mysqli_free_result($res);
        }
-       if ($strict_on) {
-               $tmp = ob_get_contents();
-               ob_end_clean();
-               if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                       printf("[009a] Strict Standards warning missing\n");
-               } else {
-                       $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-               }
-               print trim($tmp) . "\n";
-       }
        printf("[010] %d\n", $i);
 
        if (!mysqli_multi_query($link, "SELECT 1 AS num, 'a' AS somechar; SELECT 2 AS num, 'a' AS somechar; SELECT 3 AS num, 'a' AS somechar"))
@@ -151,12 +120,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
 [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
 [010] 7
 
 Warning: mysqli_multi_query(): Couldn't fetch mysqli in %s on line %d
 NULL
-done!
\ No newline at end of file
+done!
index c36920e1ecc85a7df3b85d823fa2cb2909ea1946..37265696a4418362784397d38f806ab17f264b1e 100644 (file)
@@ -10,12 +10,6 @@ require_once('skipifconnectfailure.inc');
 <?php
        require_once("connect.inc");
 
-       $strict_on = false;
-       if (defined('E_STRICT')) {
-               error_reporting(((int)ini_get('error_reporting')) | E_STRICT );
-               $strict_on = true;
-       }
-
        $tmp    = NULL;
        $link   = NULL;
 
@@ -27,50 +21,21 @@ require_once('skipifconnectfailure.inc');
 
        require('table.inc');
 
-       if ($strict_on)
-               ob_start();
-
        if (false !== ($tmp = mysqli_next_result($link)))
                printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
 
-       if ($strict_on) {
-               $tmp = ob_get_contents();
-               ob_end_clean();
-               if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                       printf("[003a] Strict Standards warning missing\n");
-               } else {
-                       $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-               }
-               print trim($tmp) . "\n";
-               ob_start();
-       }
-
        $res = mysqli_query($link, "SELECT 1 AS res");
        if (false !== ($tmp = mysqli_next_result($link)))
                printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
 
-       if ($strict_on) {
-               $tmp = ob_get_contents();
-               ob_end_clean();
-               if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                       printf("[004a] Strict Standards warning missing\n");
-               } else {
-                       $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-               }
-               print trim($tmp) . "\n";
-       }
-
        mysqli_free_result($res);
 
-       function func_test_mysqli_next_result($link, $query, $offset, $num_results, $strict_on) {
+       function func_test_mysqli_next_result($link, $query, $offset, $num_results) {
 
                if (!mysqli_multi_query($link, $query))
                        printf("[%03d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link));
 
                $i = 0;
-               if ($strict_on)
-                       ob_start();
-
                do {
                        if ($res = mysqli_store_result($link)) {
                                mysqli_free_result($res);
@@ -78,17 +43,6 @@ require_once('skipifconnectfailure.inc');
                        }
                } while (true === mysqli_next_result($link));
 
-               if ($strict_on) {
-                       $tmp = ob_get_contents();
-                       ob_end_clean();
-                       if (!preg_match('@Strict Standards: mysqli_next_result\(\): There is no next result set@ismU', $tmp)) {
-                               printf("[%03d] Strict Standards warning missing\n", $offset + 1);
-                       } else {
-                               $tmp = trim(preg_replace('@Strict Standards: mysqli_next_result\(\).*on line \d+@ism', '', $tmp));
-                       }
-                       print trim($tmp) . "\n";
-               }
-
                if ($i !== $num_results) {
                        printf("[%03d] Expecting %d result(s), got %d result(s)\n", $offset + 2, $num_results, $i);
                }
@@ -104,9 +58,9 @@ require_once('skipifconnectfailure.inc');
 
        }
 
-       func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3, $strict_on);
-       func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2, $strict_on);
-       func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1, $strict_on);
+       func_test_mysqli_next_result($link, "SELECT 1 AS a; SELECT 1 AS a, 2 AS b; SELECT id FROM test ORDER BY id LIMIT 3", 5, 3);
+       func_test_mysqli_next_result($link, "SELECT 1 AS a; INSERT INTO test(id, label) VALUES (100, 'y'); SELECT 1 AS a, 2 AS b", 8, 2);
+       func_test_mysqli_next_result($link, "DELETE FROM test WHERE id >= 100; SELECT 1 AS a; ", 11, 1);
 
        mysqli_close($link);
 
@@ -119,6 +73,16 @@ 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
+
+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
+
+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
+
+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
+
+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
+
 Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d
 NULL
-done!
\ No newline at end of file
+done!