Skip to content

Remove deprecated utf8_encode() from the pwned-password check - #568

Open
thisismyurl wants to merge 1 commit into
devgeniem:masterfrom
thisismyurl:fix/php82-drop-deprecated-utf8-encode
Open

Remove deprecated utf8_encode() from the pwned-password check#568
thisismyurl wants to merge 1 commit into
devgeniem:masterfrom
thisismyurl:fix/php82-drop-deprecated-utf8-encode

Conversation

@thisismyurl

Copy link
Copy Markdown

PHP 8.2 housekeeping. Security::check_password_pwnd_status() wraps its hash in utf8_encode(), which is deprecated as of PHP 8.2. Here the argument is strtoupper( sha1( $password ) ), which is always a pure-ASCII hex string, so utf8_encode() returns it unchanged and the call is a no-op.

Dropping it removes the deprecation notice with no change to $password_hash or the downstream HIBP range lookup. I went with removing it rather than swapping in mb_convert_encoding(), since there's nothing to convert. Happy to use the wrapper instead if you'd prefer.

Clean codebase to work in, thanks for open-sourcing the theme base.

(full disclosure: AI helped me spot this; the change and this note are mine.)

utf8_encode() is deprecated as of PHP 8.2. Here it wraps
strtoupper( sha1( $password ) ), which is always a pure-ASCII hex
string, so the call is a no-op: utf8_encode() returns that string
unchanged. Dropping it removes the deprecation notice with no change to
$password_hash or the downstream HIBP range lookup.
Copilot AI review requested due to automatic review settings July 14, 2026 13:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes a PHP 8.2 deprecation warning by dropping utf8_encode() from the Have I Been Pwned password-range check, where the input is already an ASCII-only SHA1 hex string and the call is therefore a no-op.

Changes:

  • Remove deprecated utf8_encode() wrapping around strtoupper( sha1( $password ) ) in Security::check_password_pwnd_status().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants