Skip to content

Commit 5483d90

Browse files
schlesseraclaude
andcommitted
Refuse commands that change how WordPress is loaded in a single process
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 537dfec commit 5483d90

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/Context/FeatureContext.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,11 @@ function ( $matches ) use ( $batch_variables ) {
17021702
throw new RuntimeException( "Only WP-CLI commands can run in a single process, got: {$command}" );
17031703
}
17041704

1705+
// These change how WordPress is loaded, which has already happened for every command but the first.
1706+
if ( preg_match( '/(?:^|\s)--(?:require|path|url|skip-plugins|skip-themes|skip-packages|context|exec|ssh|http)(?:[=\s]|$)/', $command ) ) {
1707+
throw new RuntimeException( "Commands that change how WordPress is loaded cannot share a process, got: {$command}" );
1708+
}
1709+
17051710
$rows[] = [ substr( $command, 3 ), $save ];
17061711
}
17071712

@@ -1734,7 +1739,8 @@ function ( $matches ) use ( $batch_variables ) {
17341739
}
17351740

17361741
if ( 0 !== $result->return_code ) {
1737-
throw new RuntimeException( "Running the commands in a single process failed:\n{$result->stderr}\n{$result->stdout}" );
1742+
$stdout = trim( (string) preg_replace( '/^' . $started . '\d+$/m', '', $result->stdout ) );
1743+
throw new RuntimeException( "Running the commands in a single process failed:\n{$result->stderr}\n{$stdout}" );
17381744
}
17391745

17401746
$position = strrpos( $result->stdout, $marker );

0 commit comments

Comments
 (0)