From 63a994c375dde2f30b346a3e1991c914f5c14059 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 3 Dec 2026 15:37:19 +0000 Subject: [PATCH] Ignore custom role keys in `wp role reset --all` 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 Claude-Session: https://claude.ai/code/session_01UWTd5oVnmAsBjaCvdBJ8ax --- features/roles.feature | 13 +++++++++++++ src/Role_Command.php | 1 + 2 files changed, 14 insertions(+) diff --git a/features/roles.feature b/features/roles.feature index 59643757..dc58658f 100644 --- a/features/roles.feature +++ b/features/roles.feature @@ -84,6 +84,19 @@ Feature: Manage WordPress roles Success: No roles needed resetting. """ + When I run `wp role reset --all custom-role author` + Then STDOUT should be: + """ + Custom role 'custom-role' not affected. + No changes necessary for 'administrator' role. + No changes necessary for 'editor' role. + No changes necessary for 'author' role. + No changes necessary for 'contributor' role. + No changes necessary for 'subscriber' role. + Success: No roles needed resetting. + """ + And STDERR should be empty + When I try `wp role reset custom-role` Then STDERR should contain: """ diff --git a/src/Role_Command.php b/src/Role_Command.php index 7b6df3d4..c059d333 100644 --- a/src/Role_Command.php +++ b/src/Role_Command.php @@ -295,6 +295,7 @@ public function reset( $args, $assoc_args ) { $before = []; if ( Utils\get_flag_value( $assoc_args, 'all' ) ) { + $args = []; foreach ( $default_roles as $role ) { $before[ $role ] = get_role( $role ); remove_role( $role );