Conversation
Remove the stale workaround for #164 (merged in decc620) that unset backup codes from available providers — require_ordinary_provider() already handles this. Handle get_available_providers_for_user() returning a WP_Error, a change introduced in WordPress/two-factor#586. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a fatal error in after_provider_deactivated() when the upstream Two-Factor plugin returns a WP_Error from Two_Factor_Core::get_available_providers_for_user(), and adds coverage to prevent regressions.
Changes:
- Remove the stale workaround that unsets Backup Codes from the available providers list.
- Treat
WP_Errorfromget_available_providers_for_user()as “no providers available” and clear the 2FA session meta accordingly. - Add a PHPUnit test validating that
after_provider_deactivated()does not fatal and clears the session when aWP_Erroris returned.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
wporg-two-factor.php |
Removes the Backup Codes workaround and adds WP_Error handling when checking available providers. |
tests/test-wporg-two-factor.php |
Adds a regression test to ensure deactivation handling is safe when available providers resolution returns WP_Error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
07c13aa to
01eee37
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ites - require_ordinary_provider(): Clean up raw user meta when stripping all providers, preventing the WP_Error that blocks users from logging in. - REST API 2fa_available_providers field: Guard against WP_Error return. - after_provider_deactivated(): Guard against WP_Error return (previous commit). Fixes the backwards-incompatible change introduced in WordPress/two-factor#586. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
01eee37 to
702dbf4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63529b3 to
1d1400a
Compare
Summary
Fixes fatal errors and login failures on wp.org caused by
get_available_providers_for_user()returning aWP_Errorafter the backwards-incompatible change in WordPress/two-factor#586.require_ordinary_provider(): Clean up the raw user meta when stripping all providers, soget_available_providers_for_user()returns an empty array instead of aWP_Error. This is the root cause fix — it was blocking users from logging in with "You have Two Factor method(s) enabled, but the provider(s) no longer exist."after_provider_deactivated(): Remove the stale workaround for Require an "ordinary" provider to use Backup Codes #164 (landed in decc620) and guard againstWP_Error. This fixes theCannot use object of type WP_Error as arrayfatal.2fa_available_providersfield: Guard againstWP_Errorreturn fromget_available_providers_for_user().Test plan
🤖 Generated with Claude Code