From ea6c96fced76d163effc3483c18c70df877823cf Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Mon, 13 Feb 2023 09:06:50 +0000 Subject: [PATCH] External Libraries: Prevent a PHP 8.1 deprecation notice in `PasswordHash::gensalt_blowfish()`. This changeset uses an `(int)` cast to prevent a PHP 8.1 deprecation notice for "Implicit conversation from float to int loses precision" in `PasswordHash::gensalt_blowfish()`. Props hanshenrik, jrf, desrosj, costdev. Fixes #56340. git-svn-id: https://develop.svn.wordpress.org/trunk@55310 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-phpass.php | 4 ++-- tests/phpunit/tests/passwordHash.php | 35 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/tests/passwordHash.php diff --git a/src/wp-includes/class-phpass.php b/src/wp-includes/class-phpass.php index 5411b36483..055925b20f 100644 --- a/src/wp-includes/class-phpass.php +++ b/src/wp-includes/class-phpass.php @@ -173,8 +173,8 @@ class PasswordHash { $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; $output = '$2a$'; - $output .= chr(ord('0') + $this->iteration_count_log2 / 10); - $output .= chr(ord('0') + $this->iteration_count_log2 % 10); + $output .= chr((int)(ord('0') + $this->iteration_count_log2 / 10)); + $output .= chr((ord('0') + $this->iteration_count_log2 % 10)); $output .= '$'; $i = 0; diff --git a/tests/phpunit/tests/passwordHash.php b/tests/phpunit/tests/passwordHash.php new file mode 100644 index 0000000000..a764159e09 --- /dev/null +++ b/tests/phpunit/tests/passwordHash.php @@ -0,0 +1,35 @@ +expectNotToPerformAssertions(); + + $hasher = new PasswordHash( 8, true ); + $hasher->gensalt_blowfish( 'a password string' ); + } + +}