summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDharman <tekiela246@gmail.com>2021-01-20 22:50:55 +0000
committerNikita Popov <nikita.ppv@gmail.com>2021-03-15 14:55:31 +0100
commit5e1056edb614fbec5ffbc6b49e5cd714542a455d (patch)
treed98fe7b60f6c8cd95ea20686cbf828a8067480e8
parentb82b85709d8017b94a34570bbb694a97ab26e71a (diff)
downloadphp-git-5e1056edb614fbec5ffbc6b49e5cd714542a455d.tar.gz
Change the default error mode of mysqli
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.
-rw-r--r--UPGRADING5
-rw-r--r--ext/mysqli/mysqli.c4
-rw-r--r--ext/mysqli/tests/connect.inc1
-rw-r--r--ext/mysqli/tests/mysqli_incomplete_initialization.phpt1
4 files changed, 9 insertions, 2 deletions
diff --git a/UPGRADING b/UPGRADING
index db0e1d4843..2bf657e740 100644
--- 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
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 50f068f369..85847e7a3b 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -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;
}
diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc
index 0fb3cff66c..e8f56cf249 100644
--- a/ext/mysqli/tests/connect.inc
+++ b/ext/mysqli/tests/connect.inc
@@ -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;
diff --git a/ext/mysqli/tests/mysqli_incomplete_initialization.phpt b/ext/mysqli/tests/mysqli_incomplete_initialization.phpt
index 533ea10af1..399ad74274 100644
--- a/ext/mysqli/tests/mysqli_incomplete_initialization.phpt
+++ b/ext/mysqli/tests/mysqli_incomplete_initialization.phpt
@@ -7,6 +7,7 @@ require_once('skipif.inc');
--FILE--
<?php
+mysqli_report(MYSQLI_REPORT_OFF);
$mysqli = new mysqli();
@$mysqli->__construct('doesnotexist');
$mysqli->close();