You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 87e1904
Browse filesBrowse the repository at this point in the historyBrowse files
Limit who can remove a post from its workflow (#211)
* fix: limit who can remove a post from its workflow
Removing a post from its workflow, replacing its workflow, or re-seating
it in the same one is now limited to the Workflow override roles
(`bypass_workflow_roles`, administrators by default). Giving an
unassigned post its first workflow stays open to anyone who can edit it,
and a write with no logged-in user is still treated as a system actor.
A post with any stored sequence value, including one naming a deleted
workflow or one that is not a number, counts as already assigned.
The limit lives in StatusManager::remove_sequence() and
assign_sequence(), so the REST route, the remove-from-workflow ability
(and so MCP), the editor and extensions all get it. Anyone else gets a
403 `vip_workflows_removal_restricted` that names the roles to ask, and
nothing is written or audited. Removals stay audited as before.
The publish-veto messages, server and client, now name who to ask
instead of implying removal is available, and the deleted-workflow
message says who can remove the post. Settings::get_override_role_names()
gives the display names, served to the clients as
`guard.override_roles`. The editor's Workflow row no longer offers the
picker or Remove from workflow to a user outside the override roles on
a post that already has a workflow; it says who can change it instead.
The Workflow override setting description lists the new grant.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: describe the workflow removal limit in SPEC.md
Edits the bypass-list glossary line, N2, the sequence route and
remove-from-workflow ability rows, the Bypass and publish boundary guard
notes, Sequences' assignment rule and strand footgun, and Publish
boundary's "Two ways through", Always true, footgun and code lines. Also
updates the Workflow row description in docs/reference/admin-ui.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: locate the MCP adapter from the plugins directory
The MCP refusal test found the adapter's autoloader with
dirname( __DIR__, 4 ), which only reaches wp-content/plugins because of how
wp-env mounts the plugin. From a repository checkout it points at the repo
root, which reads as a path that can never exist. Use WP_PLUGIN_DIR, as
GuidelineContextProviderKnowledgeTest does, and say why the autoloader is
required here: the tests environment installs the adapter but never
activates it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: cover the save guard's ask sentence with override roles
The WorkflowSaveGuard veto tests used a guard payload without
override_roles, so the sentence naming who to ask was never reached through
the component. Add cases for a refused publish with one role, a refused
status change with two, and a post in a deleted workflow, each asserting
the full message.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: check the workflow change limit before the target sequence
assign_sequence() checked the override-role limit only after it had
looked up the target sequence and found the post's entry stage. A user
outside the override roles replacing a post's workflow could get a 400
about a missing sequence or a region the sequence has no stage for, fix
it, and then get the 403 naming who to ask.
The limit now runs right after the post is resolved, whenever the post
already has a workflow. A first assignment of an unassigned post is
unchanged: it is open to anyone with edit_post and still gets the stage
check's 400. The REST route and the remove-from-workflow ability had no
check ahead of StatusManager that needed moving.
Tests: integration cases for an author replacing with an unseatable or
missing sequence (403), an override user with the same unseatable
sequence (400), and a first assignment with it (400). Unit fixtures
updated for the new lookup order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: show a workflow the user can't change as plain text
For a post that has a workflow (or a deleted one), a user outside the
Workflow override roles now sees the Workflow row's value as plain text,
the way core's Status row reads for someone who can't publish: no
trigger, no popover, no picker and no Remove button. The popover that
named the override roles is gone, along with the client copy of that
sentence, which nothing else used.
Users in the override roles keep the picker, and a post with no
workflow stays selectable for everyone. The server's refusal and its
message are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: describe the read-only Workflow row
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@@ -145,7 +146,7 @@ function register_get_available_transitions(): void {
145
146
),
146
147
'guard' => array(
147
148
'type' => 'object',
148
-
'description' => __( 'What performing one of these transitions would set off. `current_region` is the editorial region (draft/pending/private/publish) of the post’s stage, or null when it cannot be resolved; a move whose target region differs, with either side being publish, is refused for a user whose `can_bypass` is false. `agent_pending` is true when an AI agent is mid-run on this post, in which case any transition out of the stage stops it and must be confirmed with transition-post’s acknowledge_warnings.', 'vip-workflows' ),
149
+
'description' => __( 'What performing one of these transitions would set off. `current_region` is the editorial region (draft/pending/private/publish) of the post’s stage, or null when it cannot be resolved; a move whose target region differs, with either side being publish, is refused for a user whose `can_bypass` is false. `agent_pending` is true when an AI agent is mid-run on this post, in which case any transition out of the stage stops it and must be confirmed with transition-post’s acknowledge_warnings. `override_roles` names the roles that can skip these rules and that alone can remove the post from its workflow or change its workflow: who to ask when `can_bypass` is false.', 'vip-workflows' ),
Copy file name to clipboardExpand all lines: vip-workflows/includes/abilities/tools/remove-from-workflow.php
+7-8Lines changed: 7 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,13 @@
2
2
/**
3
3
* Remove From Workflow ability.
4
4
*
5
-
* The Abilities-API half of the publish veto's escape hatch.
5
+
* The Abilities-API counterpart of the editor's "Remove from workflow".
6
6
*
7
-
* A non-bypass user's status change across the publish boundary is refused at
8
-
* the save layer, and the refusal names exactly two ways through: move the post
9
-
* through the workflow to a published stage, or take it out of the workflow —
10
-
* which is recorded. Both were reachable from the UI; only the first was
11
-
* reachable from an ability, so an agent asked to "remove this from its workflow
12
-
* and publish it" could not do the thing the veto itself told it to do.
7
+
* Removal is limited to the workflow override roles, the same people the
8
+
* publish veto tells everyone else to ask. The limit is
9
+
* StatusManager::remove_sequence()'s, not this ability's: any other user with
10
+
* edit access gets that method's 403 naming who to ask, so an agent acting for
11
+
* them learns the same thing the editor would tell them.
13
12
*
14
13
* @package VIPWorkflows
15
14
*/
@@ -83,7 +82,7 @@ function register_remove_from_workflow(): void {
83
82
'vip-workflows/remove-from-workflow',
84
83
array(
85
84
'label' => __( 'Remove from workflow', 'vip-workflows' ),
86
-
'description' => __( 'Takes a post out of its workflow, leaving its published status exactly as it is. The removal is recorded in the workflow log and cannot be undone: re-assigning a workflow later starts the post at the first stage of its region. This is the audited escape from the publish guard — prefer moving the post through the workflow to a published stage where that is possible.', 'vip-workflows' ),
85
+
'description' => __( 'Takes a post out of its workflow, leaving its published status exactly as it is. The removal is recorded in the workflow log and cannot be undone: re-assigning a workflow later starts the post at the first stage of its region. Only users in a workflow override role can remove a post; anyone else gets an error naming the roles to ask. Prefer moving the post through the workflow to a published stage.', 'vip-workflows' ),
error_log( sprintf( '[VIP Workflows] Post %d is workflow-managed but its sequence could not be resolved while building the publish-veto message.', $post_id ) );
410
420
411
-
returnsprintf(
412
-
/* translators: %s: post title. */
413
-
__( '“%s” is in a deleted workflow. Remove it from the workflow to change its status.', 'vip-workflows' ),
414
-
$post_title
421
+
returnself::with_ask_sentence(
422
+
sprintf(
423
+
/* translators: %s: post title. */
424
+
__( '“%s” is in a deleted workflow, so its status can’t be changed.', 'vip-workflows' ),
425
+
$post_title
426
+
),
427
+
'remove',
428
+
$roles
415
429
);
416
430
}
417
431
@@ -423,20 +437,75 @@ private function veto_message( int $post_id, string $post_title, string $target_
423
437
}
424
438
425
439
if ( 'publish' === $this->status_manager->status_to_region( $target_status ) ) {
426
-
returnsprintf(
440
+
returnself::with_ask_sentence(
441
+
sprintf(
442
+
/* translators: 1: post title, 2: workflow (sequence) name. */
443
+
__( '“%1$s” is in the “%2$s” workflow, so it can’t be published directly. Move it through the workflow to a published stage.', 'vip-workflows' ),
444
+
$post_title,
445
+
$sequence->name
446
+
),
447
+
'publish',
448
+
$roles
449
+
);
450
+
}
451
+
452
+
returnself::with_ask_sentence(
453
+
sprintf(
427
454
/* translators: 1: post title, 2: workflow (sequence) name. */
428
-
__( '“%1$s” is in the “%2$s” workflow, so it can’t be published directly. Move it through the workflow to a published stage.', 'vip-workflows' ),
455
+
__( '“%1$s” is in the “%2$s” workflow, so its status can’t be changed directly. Move it through the workflow instead.', 'vip-workflows' ),
429
456
$post_title,
430
457
$sequence->name
431
-
);
458
+
),
459
+
'change',
460
+
$roles
461
+
);
462
+
}
463
+
464
+
/**
465
+
* Append the sentence naming who to ask, when there is anyone to name.
466
+
*
467
+
* A separate sentence, not a clause of the first, so each translatable
468
+
* string is a whole sentence and the message stays readable when no role
469
+
* holds the override.
470
+
*
471
+
* @param string $message First sentence of the veto message.
472
+
* @param string $action What to ask for: `publish`, `change` or `remove`.
473
+
* @param string[] $roles Override role display names.
0 commit comments