Skip to content

fix php 8.5 deprecated message#762

Merged
kasparsd merged 1 commit intoWordPress:masterfrom
masteradhoc:patch-1
Feb 1, 2026
Merged

fix php 8.5 deprecated message#762
kasparsd merged 1 commit intoWordPress:masterfrom
masteradhoc:patch-1

Conversation

@masteradhoc
Copy link
Collaborator

@masteradhoc masteradhoc commented Jan 31, 2026

Fixes #761

What?

Fixes a PHP deprecation warning caused by using null as an array offset when determining the primary two-factor provider.

Why?

PHP 7.4+ emits a deprecation notice when null is used as an array key. This can happen if no primary provider is selected for a user, resulting in noisy logs and potential issues on stricter setups.

How?

Explicitly guard against null (or empty string) before using it as an array offset.

Testing Instructions

  1. setup totp, backup codes and email codes for a user
  2. go to /wp-admin/users.php
  3. see the deprecation message
  4. apply fix
  5. go to /wp-admin/users.php - no deprecation message anymore showing up

Screenshots or screencast

Changelog Entry

Fixed - Prevent PHP 7.4+ deprecation warning when resolving the primary two-factor provider.

@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: masteradhoc <masteradhoc@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@kasparsd kasparsd merged commit 8190ca4 into WordPress:master Feb 1, 2026
27 of 29 checks passed
@masteradhoc masteradhoc deleted the patch-1 branch February 1, 2026 10:30
@jeffpaul jeffpaul added this to the 0.15.0 milestone Feb 2, 2026
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.

Deprecated: Using null as an array offset is deprecated, use an empty string instead in /class-two-factor-core.php on line 657

3 participants