Skip to content

Commit 5e1056e

Browse files
kamil-tekielanikic
authored andcommitted
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 phpGH-6629.
1 parent b82b857 commit 5e1056e

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

UPGRADING

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ PHP 8.1 UPGRADE NOTES
7575
internally previously.
7676
. The MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH option no longer has an effect.
7777
. The MYSQLI_STORE_RESULT_COPY_DATA option no longer has an effect.
78+
. The default error handling mode has been changed from "silent" to
79+
"exceptions". See https://www.php.net/manual/en/mysqli-driver.report-mode.php
80+
for details of behavior changes and how to explicitly set this attribute. To
81+
keep the old behavior, use mysqli_report(MYSQLI_REPORT_OFF);
82+
RFC: https://wiki.php.net/rfc/mysqli_default_errmode
7883

7984
- MySQLnd:
8085
. The mysqlnd.fetch_copy_data ini setting has been removed. However, this

ext/mysqli/mysqli.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ static PHP_GINIT_FUNCTION(mysqli)
521521
mysqli_globals->default_pw = NULL;
522522
mysqli_globals->default_socket = NULL;
523523
mysqli_globals->reconnect = 0;
524-
mysqli_globals->report_mode = 0;
524+
mysqli_globals->report_mode = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;;
525525
mysqli_globals->allow_local_infile = 0;
526526
mysqli_globals->local_infile_directory = NULL;
527527
mysqli_globals->rollback_on_cached_plink = FALSE;
@@ -826,7 +826,7 @@ PHP_RINIT_FUNCTION(mysqli)
826826
#endif
827827
MyG(error_msg) = NULL;
828828
MyG(error_no) = 0;
829-
MyG(report_mode) = 0;
829+
MyG(report_mode) = MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT;
830830

831831
return SUCCESS;
832832
}

ext/mysqli/tests/connect.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
$driver = new mysqli_driver;
10+
$driver->report_mode = MYSQLI_REPORT_OFF;
1011

1112
$host = getenv("MYSQL_TEST_HOST") ?: "127.0.0.1";
1213
$port = getenv("MYSQL_TEST_PORT") ?: 3306;

ext/mysqli/tests/mysqli_incomplete_initialization.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require_once('skipif.inc');
77
--FILE--
88
<?php
99

10+
mysqli_report(MYSQLI_REPORT_OFF);
1011
$mysqli = new mysqli();
1112
@$mysqli->__construct('doesnotexist');
1213
$mysqli->close();

0 commit comments

Comments
 (0)