Repository navigation
Ignore custom role keys in wp role reset --all - #91
Merged
Merged
Conversation
With `--all`, the default roles were appended to the user-supplied role keys, so a custom key passed alongside the flag stayed in the list to check. It had no recorded "before" state, which raised an "Undefined array key" warning and counted the untouched custom role as reset. `--all` always resets exactly the default roles, so start from an empty list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5oVnmAsBjaCvdBJ8ax
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ernilambar
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wp role reset --all <custom-role>printed a PHP warning and reported a custom role as reset, even though custom roles aren't touched.With
--all, the default roles were appended to the role keys passed on the command line. A custom key passed alongside the flag therefore stayed in the list of roles to compare afterwards, but it never got a "before" snapshot. The$after[ $role_key ] != $before[ $role_key ]check then read an undefined array key (Warning: Undefined array key "custom-role"), counted the role as changed, and the summary was off.Before this change:
After:
--allalways resets exactly the default roles, so the fix starts from an empty list in that branch instead of the user-supplied keys.Testing
features/roles.featurethat runswp role reset --all custom-role authorand asserts the output matches a plain--allwith an empty STDERR. It fails without the fix and passes with it.features/passes locally (6 scenarios, 110 steps) withWP_CLI_TEST_DBTYPE=sqlite; PHPCS and gherkin-lint pass. PHPStan was not run locally.Generated by Claude Code
Summary by CodeRabbit
wp role reset --allwhen custom role names are also provided. Custom roles are excluded from the reset, while unchanged default roles are reported as before.