Skip to content

Fix two latent VIPCS phpcs violations blocking CI - #1037

Merged
GaryJones merged 1 commit into
developfrom
GaryJones/fix-cli-nopaging-phpcs
Aug 18, 2026
Merged

GaryJones merged 1 commit into
developfrom
GaryJones/fix-cli-nopaging-phpcs

Conversation

@GaryJones

Copy link
Copy Markdown
Contributor

Summary

CI recently began failing the PHP coding-standards job on branches that had not touched the offending code. The cause is a combination of two things. The repository has no committed composer.lock, so each CI run installs the latest automattic/vipwpcs matching ^3.0; a newer 3.x release tightened two sniffs. The php-lint workflow also caches phpcs results with broad restore keys, so develop's runs keep restoring a stale cache that marks the affected files clean and never re-evaluates them under the newer ruleset. The violations are therefore latent on develop and only surface when a pull request happens to run against a cold cache — at which point an unrelated PR is blocked by a failure it did not introduce.

Two lines are flagged. The WP-CLI status-migration command in class-cli.php queries with posts_per_page => -1, which the NoPaging sniff prohibits in a VIP context; here it is correct, because a one-off CLI migration should fetch every matching ID in a single pass and already limits itself to 'fields' => 'ids'. Separately, a test callback on the wp_redirect filter throws to unwind the handler before it reaches exit, which the newer AlwaysReturnInFilter sniff now flags under a new TerminatingInsteadOfReturn sub-code that the existing ignore did not cover.

Rather than weaken the ruleset, both are addressed with justified, narrowly-scoped phpcs:ignore comments that document why the pattern is intentional. The existing ignore on the test is extended to list both sub-sniffs.

With these in place, a cold composer cs run is clean across the whole repository, so CI passes on any branch regardless of cache state.

Test plan

  • rm -f .phpcs-cache && composer cs exits 0 across the whole repository

A newer automattic/vipwpcs 3.x release, floated in because the repo has no
committed composer.lock, started flagging two existing lines: the WP-CLI
status-migration query's posts_per_page => -1, and the wp_redirect test
callback that throws to unwind the handler. Both are latent on develop but
hidden by the phpcs result cache, so they only surface on a cold-cache CI run
and block otherwise-clean pull requests.

Add a justified ignore for NoPaging on the CLI query, where fetching every
matching ID in one pass is correct for a one-off migration, and extend the
test's existing AlwaysReturnInFilter ignore to cover the new
TerminatingInsteadOfReturn sub-sniff. Both suppressions document why the
pattern is intentional rather than weakening the ruleset.
@GaryJones
GaryJones requested a review from a team as a code owner August 18, 2026 11:10
@GaryJones GaryJones self-assigned this Aug 18, 2026
@GaryJones GaryJones added the type: bug Something isn't working label Aug 18, 2026
@GaryJones GaryJones added this to the Next milestone Aug 18, 2026
@GaryJones
GaryJones merged commit fee4cff into develop Aug 18, 2026
10 checks passed
@GaryJones
GaryJones deleted the GaryJones/fix-cli-nopaging-phpcs branch August 18, 2026 13:48
@GaryJones GaryJones mentioned this pull request Aug 18, 2026
2 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant