From 4eb28733b46e346beb934f26cdbb27f11c430fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 11 Nov 2025 10:43:44 -0300 Subject: [PATCH 1/3] Suppress BaconQrCode PHP 8.4 deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .../classes/Plugins/TwoFactor/Application.php | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/libraries/classes/Plugins/TwoFactor/Application.php b/libraries/classes/Plugins/TwoFactor/Application.php index 160b440c81..4361e0833b 100644 --- a/libraries/classes/Plugins/TwoFactor/Application.php +++ b/libraries/classes/Plugins/TwoFactor/Application.php @@ -16,6 +16,10 @@ use PragmaRX\Google2FAQRCode\Google2FA; use function __; use function extension_loaded; +use function restore_error_handler; +use function set_error_handler; + +use const E_DEPRECATED; /** * HOTP and TOTP based two-factor authentication @@ -89,11 +93,20 @@ class Application extends TwoFactorPlugin public function setup() { $secret = $this->twofactor->config['settings']['secret']; - $inlineUrl = $this->google2fa->getQRCodeInline( - 'phpMyAdmin (' . $this->getAppId(false) . ')', - $this->twofactor->user, - $secret - ); + + // Suppress PHP 8.4 deprecation from third-party package + set_error_handler(static function (int $level): bool { + return $level === E_DEPRECATED; + }); + try { + $inlineUrl = $this->google2fa->getQRCodeInline( + 'phpMyAdmin (' . $this->getAppId(false) . ')', + $this->twofactor->user, + $secret + ); + } finally { + restore_error_handler(); + } return $this->template->render('login/twofactor/application_configure', [ 'image' => $inlineUrl, From 25e44d52ea437bf05e3c4b39bd430054c62e6cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 11 Nov 2025 12:51:35 -0300 Subject: [PATCH 2/3] Suppress Brick\Math\BigInteger PHP 8.1 deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- .../classes/WebAuthn/WebauthnLibServer.php | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/libraries/classes/WebAuthn/WebauthnLibServer.php b/libraries/classes/WebAuthn/WebauthnLibServer.php index 410a7f2c0c..06db8ec5e5 100644 --- a/libraries/classes/WebAuthn/WebauthnLibServer.php +++ b/libraries/classes/WebAuthn/WebauthnLibServer.php @@ -21,9 +21,12 @@ use Webmozart\Assert\Assert; use function array_map; use function base64_encode; use function json_decode; +use function restore_error_handler; +use function set_error_handler; use function sodium_base642bin; use function sodium_bin2base64; +use const E_DEPRECATED; use const SODIUM_BASE64_VARIANT_ORIGINAL; use const SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING; @@ -142,12 +145,21 @@ final class WebauthnLibServer implements Server 'timeout' => 60000, ]); Assert::isInstanceOf($requestOptions, PublicKeyCredentialRequestOptions::class); - $server->loadAndCheckAssertionResponse( - $assertionResponseJson, - $requestOptions, - $userEntity, - $request - ); + + // Suppress PHP 8.1 deprecation from third-party package + set_error_handler(static function (int $level): bool { + return $level === E_DEPRECATED; + }); + try { + $server->loadAndCheckAssertionResponse( + $assertionResponseJson, + $requestOptions, + $userEntity, + $request + ); + } finally { + restore_error_handler(); + } } public function parseAndValidateAttestationResponse( @@ -191,11 +203,20 @@ final class WebauthnLibServer implements Server ]; $credentialCreationOptions = PublicKeyCredentialCreationOptions::createFromArray($creationOptionsArray); Assert::isInstanceOf($credentialCreationOptions, PublicKeyCredentialCreationOptions::class); - $publicKeyCredentialSource = $server->loadAndCheckAttestationResponse( - $attestationResponse, - $credentialCreationOptions, - $request - ); + + // Suppress PHP 8.1 deprecation from third-party package + set_error_handler(static function (int $level): bool { + return $level === E_DEPRECATED; + }); + try { + $publicKeyCredentialSource = $server->loadAndCheckAttestationResponse( + $attestationResponse, + $credentialCreationOptions, + $request + ); + } finally { + restore_error_handler(); + } return $publicKeyCredentialSource->jsonSerialize(); } From 0fd0afec9275659a95e64b3f775217a3b1db3ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 11 Nov 2025 14:41:40 -0300 Subject: [PATCH 3/3] Wrap strftime function to suppress deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Util.php | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 7d957f42a8..de3d7f0902 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -65,8 +65,10 @@ use function preg_replace; use function random_bytes; use function range; use function reset; +use function restore_error_handler; use function round; use function rtrim; +use function set_error_handler; use function set_time_limit; use function sort; use function sprintf; @@ -85,6 +87,7 @@ use function time; use function trim; use function uksort; +use const E_DEPRECATED; use const ENT_COMPAT; use const ENT_QUOTES; use const PHP_INT_SIZE; @@ -716,14 +719,12 @@ class Util $date = (string) preg_replace( '@%[aA]@', - // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated - $dayOfWeek[(int) @strftime('%w', (int) $timestamp)], + $dayOfWeek[(int) self::strftime('%w', (int) $timestamp)], $format ); $date = (string) preg_replace( '@%[bB]@', - // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated - $month[(int) @strftime('%m', (int) $timestamp) - 1], + $month[(int) self::strftime('%m', (int) $timestamp) - 1], $date ); @@ -739,8 +740,7 @@ class Util // Can return false on windows for Japanese language // See https://github.com/phpmyadmin/phpmyadmin/issues/15830 - // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated - $ret = @strftime($date, (int) $timestamp); + $ret = self::strftime($date, (int) $timestamp); // Some OSes such as Win8.1 Traditional Chinese version did not produce UTF-8 // output here. See https://github.com/phpmyadmin/phpmyadmin/issues/10598 if ($ret === false || mb_detect_encoding($ret, 'UTF-8', true) !== 'UTF-8') { @@ -750,6 +750,20 @@ class Util return $ret; } + /** @return string|false */ + private static function strftime(string $format, ?int $timestamp = null) + { + set_error_handler(static function (int $level): bool { + return $level === E_DEPRECATED; + }); + try { + // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated + return $timestamp === null ? strftime($format) : strftime($format, $timestamp); + } finally { + restore_error_handler(); + } + } + /** * Splits a URL string by parameter * @@ -1710,8 +1724,7 @@ class Util } /* Do the replacement */ - // phpcs:ignore Generic.PHP.DeprecatedFunctions.Deprecated - return strtr((string) @strftime($string), $replace); + return strtr((string) self::strftime($string), $replace); } /**