mirror of
git://develop.git.wordpress.org/
synced 2025-02-06 15:41:08 +01:00
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
This commit is contained in:
parent
e0a9b1f4c5
commit
ea6c96fced
@ -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;
|
||||
|
35
tests/phpunit/tests/passwordHash.php
Normal file
35
tests/phpunit/tests/passwordHash.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tests for the PasswordHash external library.
|
||||
*
|
||||
* @covers PasswordHash
|
||||
*/
|
||||
class Tests_PasswordHash extends WP_UnitTestCase {
|
||||
|
||||
public static function set_up_before_class() {
|
||||
parent::set_up_before_class();
|
||||
|
||||
require_once ABSPATH . WPINC . '/class-phpass.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that PasswordHash::gensalt_blowfish() does not throw a deprecation
|
||||
* notice on PHP 8.1 for "Implicit conversion from float to int loses precision".
|
||||
*
|
||||
* Should this test fail, it will produce an error "E" in the results.
|
||||
*
|
||||
* @ticket 56340
|
||||
*
|
||||
* @covers PasswordHash::gensalt_blowfish
|
||||
*
|
||||
* @requires PHP 8.1
|
||||
*/
|
||||
public function test_gensalt_blowfish_should_not_throw_deprecation_notice_in_php81() {
|
||||
$this->expectNotToPerformAssertions();
|
||||
|
||||
$hasher = new PasswordHash( 8, true );
|
||||
$hasher->gensalt_blowfish( 'a password string' );
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user