Make WordPress Core

Opened 3 months ago

Last modified 11 days ago

#56340 new defect (bug)

PHP8.1 E_DEPRECATED in PasswordHash::gensalt_blowfish

Reported by: hanshenrik's profile hanshenrik Owned by:
Milestone: 6.2 Priority: normal
Severity: minor Version:
Component: External Libraries Keywords: has-patch php81 needs-unit-tests
Focuses: Cc:

Description (last modified by SergeyBiryukov)

since PHP8.1, PasswordHash::gensalt_blowfish risk getting E_DEPRECATED errors like

Deprecated: Implicit conversion from float 48.8 to int loses precision

in

$output .= chr((ord('0') + $this->iteration_count_log2 / 10));

the fix is simple, change it from implicit conversion to explicit conversion:

$output .= chr((int)((ord('0') + $this->iteration_count_log2 / 10)));

Attachments (2)

diff.diff (568 bytes) - added by hanshenrik 3 months ago.
diff2.diff (657 bytes) - added by hanshenrik 3 months ago.
updated diff

Download all attachments as: .zip

Change History (8)

@hanshenrik
3 months ago

This ticket was mentioned in PR #3067 on WordPress/wordpress-develop by divinity76.


3 months ago

  • Keywords has-patch added

trac: https://core.trac.wordpress.org/ticket/56340

fix PHP>=8.1 E_DEPRECATED: Deprecated: Implicit conversion from float 48.8 to int loses precision

Trac ticket: https://core.trac.wordpress.org/ticket/56340

@hanshenrik
3 months ago

updated diff

#2 @SergeyBiryukov
3 months ago

  • Description modified (diff)
  • Keywords php81 added
  • Milestone changed from Awaiting Review to 6.1

#3 @jrf
3 months ago

  • Keywords needs-unit-tests added

Fix looks good, but it would be good to have a test to safeguard this fix.

#4 @desrosj
3 weeks ago

  • Component changed from Application Passwords to External Libraries

The class being updated in the patches is technically an external library, though WordPress has made some changes to it over time (see the description of #51549).

I believe that the original intent of PHPass was to properly support password hashing on PHP < 5.5, which no longer applies to WordPress. But moving off of PHPass is a much larger discussion currently being had in #50027 and #21022.

This one off adjustment should be fine to make in the meantime, provided a few tests are added.

#5 @audrasjb
2 weeks ago

  • Milestone changed from 6.1 to 6.2

With WP 6.1 RC 1 scheduled tomorrow (Oct 10, 2022), there is not much time left to address this ticket. Given it still needs unit tests, let's move this ticket to 6.2.

Ps: if you were about to send a patch and if you feel it is realistic to commit it in the next few hours, please feel free to move this ticket back to milestone 6.1.

#6 @desrosj
11 days ago

  • Version trunk deleted
Note: See TracTickets for help on using tickets.