]> granicus.if.org Git - php/commitdiff
Change the default error mode of mysqli
authorDharman <tekiela246@gmail.com>
Wed, 20 Jan 2021 22:50:55 +0000 (22:50 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 15 Mar 2021 13:55:31 +0000 (14:55 +0100)
Make MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT the new mysqli
error reporting default. Explicitly call
mysqli_report(MYSQLI_REPORT_OFF) to preserve previous behavior.

RFC: https://wiki.php.net/rfc/mysqli_default_errmode

Closes GH-6629.

UPGRADING
ext/mysqli/mysqli.c
ext/mysqli/tests/connect.inc
ext/mysqli/tests/mysqli_incomplete_initialization.phpt

index db0e1d484393c54592baa844dd4af81467f152ad..2bf657e7409dda9b44622341b5290dd5a1ed68ea 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -75,6 +75,11 @@ PHP 8.1 UPGRADE NOTES
     internally previously.
   . The MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH option no longer has an effect.
   . The MYSQLI_STORE_RESULT_COPY_DATA option no longer has an effect.
+  . The default error handling mode has been changed from "silent" to
+    "exceptions". See https://www.php.net/manual/en/mysqli-driver.report-mode.php
+    for details of behavior changes and how to explicitly set this attribute. To
+    keep the old behavior, use mysqli_report(MYSQLI_REPORT_OFF);
+    RFC: https://wiki.php.net/rfc/mysqli_default_errmode
 
 - MySQLnd:
   . The mysqlnd.fetch_copy_data ini setting has been removed. However, this
index 50f068f369547ce1b4e825fd5346af0009d62e40..85847e7a3b67d81781e28bd546207af4be6362bd 100644 (file)
@@ -521,7 +521,7 @@ static PHP_GINIT_FUNCTION(mysqli)
        mysqli_globals->default_pw = NULL;
        mysqli_globals->default_socket = NULL;
        mysqli_globals->reconnect = 0;
-       mysqli_globals->report_mode = 0;
+       mysqli_globals->report_mode = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;;
        mysqli_globals->allow_local_infile = 0;
        mysqli_globals->local_infile_directory = NULL;
        mysqli_globals->rollback_on_cached_plink = FALSE;
@@ -826,7 +826,7 @@ PHP_RINIT_FUNCTION(mysqli)
 #endif
        MyG(error_msg) = NULL;
        MyG(error_no) = 0;
-       MyG(report_mode) = 0;
+       MyG(report_mode) = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;
 
        return SUCCESS;
 }
index 0fb3cff66c83f620b39e5d74f9a1d7e80df8b779..e8f56cf249a385b3bb9cfd8b4faf68f918b15b32 100644 (file)
@@ -7,6 +7,7 @@
     */
 
     $driver    = new mysqli_driver;
+    $driver->report_mode = MYSQLI_REPORT_OFF;
 
     $host      = getenv("MYSQL_TEST_HOST")     ?: "127.0.0.1";
     $port      = getenv("MYSQL_TEST_PORT")     ?: 3306;
index 533ea10af10c612faa83d968314df73f21fd134d..399ad74274f970b5e2ec575f1786cea3631db492 100644 (file)
@@ -7,6 +7,7 @@ require_once('skipif.inc');
 --FILE--
 <?php
 
+mysqli_report(MYSQLI_REPORT_OFF);
 $mysqli = new mysqli();
 @$mysqli->__construct('doesnotexist');
 $mysqli->close();