diff -Nru wordpress-5.8.3+dfsg1/debian/changelog wordpress-5.8.3+dfsg1/debian/changelog --- wordpress-5.8.3+dfsg1/debian/changelog 2022-01-11 01:05:34.000000000 +0000 +++ wordpress-5.8.3+dfsg1/debian/changelog 2023-05-03 12:11:14.000000000 +0000 @@ -1,3 +1,11 @@ +wordpress (5.8.3+dfsg1-1ubuntu1.1) jammy; urgency=medium + + * Fix compatibility with PHP 8.1 (LP: #1970194) + - debian/patches/lp1970194.patch: set the MySQLi error reporting off in + wp-includes/wp-db.php. + + -- Marc Deslauriers Wed, 03 May 2023 14:11:14 +0200 + wordpress (5.8.3+dfsg1-1ubuntu1) jammy; urgency=low * Merge from Debian unstable. Remaining changes: diff -Nru wordpress-5.8.3+dfsg1/debian/patches/lp1970194.patch wordpress-5.8.3+dfsg1/debian/patches/lp1970194.patch --- wordpress-5.8.3+dfsg1/debian/patches/lp1970194.patch 1970-01-01 00:00:00.000000000 +0000 +++ wordpress-5.8.3+dfsg1/debian/patches/lp1970194.patch 2023-05-03 12:11:11.000000000 +0000 @@ -0,0 +1,66 @@ +From 988c8be693e0d12aeacae30f1d4bebfb98f7e5a0 Mon Sep 17 00:00:00 2001 +From: Sergey Biryukov +Date: Sun, 8 Aug 2021 14:10:01 +0000 +Subject: [PATCH] Code Modernization: Set the MySQLi error reporting off for + PHP 8.1. + +Prior to PHP 8.1, the default error handling mode was `MYSQLI_REPORT_OFF`. An error in the extension, database, query, or the database connection returned `false` and emitted a PHP warning: +{{{ +$mysqli = new mysqli("localhost", "non-existing-user", "", ""); + +Warning: mysqli::__construct(): (HY000/2002): No connection could be made because the target machine actively refused it in ... on line ... +}}} + +From PHP 8.1 and later, the default error mode is set to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT`. An error in the extension, database, query, or the database connection throws an exception: +{{{ +$mysqli = new mysqli("localhost", "non-existing-user", "", ""); + +Fatal error: Uncaught mysqli_sql_exception: Connection refused in ...:... +}}} + +WordPress has its own error reporting and gracefully handles the database errors by inspecting the error codes. Setting the MySQLi error reporting to off avoids fatal errors due to uncaught exceptions and maintains the current behavior. + +References: +* [https://php.watch/versions/8.1/mysqli-error-mode PHP 8.1: MySQLi: Default error mode set to exceptions] +* [https://wiki.php.net/rfc/mysqli_default_errmode PHP RFC: Change Default mysqli Error Mode] + +Props ayeshrajans, jrf. +Fixes #52825. +Built from https://develop.svn.wordpress.org/trunk@51582 + + +git-svn-id: http://core.svn.wordpress.org/trunk@51193 1a063a9b-81f0-0310-95a4-ce76da25c4cd +--- + wp-includes/version.php | 2 +- + wp-includes/wp-db.php | 7 +++++++ + 2 files changed, 8 insertions(+), 1 deletion(-) + +#diff --git a/wp-includes/version.php b/wp-includes/version.php +#index 0c3c5eea88b4..334e812231bd 100644 +#--- a/wp-includes/version.php +#+++ b/wp-includes/version.php +#@@ -13,7 +13,7 @@ +# * +# * @global string $wp_version +# */ +#-$wp_version = '5.9-alpha-51581'; +#+$wp_version = '5.9-alpha-51582'; +# +# /** +# * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. +--- a/wp-includes/wp-db.php ++++ b/wp-includes/wp-db.php +@@ -1628,6 +1628,13 @@ class wpdb { + $client_flags = defined( 'MYSQL_CLIENT_FLAGS' ) ? MYSQL_CLIENT_FLAGS : 0; + + if ( $this->use_mysqli ) { ++ /* ++ * Set the MySQLi error reporting off because WordPress handles its own. ++ * This is due to the default value change from `MYSQLI_REPORT_OFF` ++ * to `MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT` in PHP 8.1. ++ */ ++ mysqli_report( MYSQLI_REPORT_OFF ); ++ + $this->dbh = mysqli_init(); + + $host = $this->dbhost; diff -Nru wordpress-5.8.3+dfsg1/debian/patches/series wordpress-5.8.3+dfsg1/debian/patches/series --- wordpress-5.8.3+dfsg1/debian/patches/series 2022-01-07 09:21:05.000000000 +0000 +++ wordpress-5.8.3+dfsg1/debian/patches/series 2023-05-03 12:10:51.000000000 +0000 @@ -7,3 +7,4 @@ 016hiding_update_information.patch 38474.patch tw_sack_encoding +lp1970194.patch