Skip to content

Fix the WPCS code execution advisory and require PHP 8.2 - #31

Open
svandragt wants to merge 2 commits into
masterfrom
update-coding-standards-wpcs-advisory
Open

svandragt wants to merge 2 commits into
masterfrom
update-coding-standards-wpcs-advisory

Conversation

@svandragt

@svandragt svandragt commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

The locked WordPress Coding Standards version has a high-severity arbitrary code execution advisory. It is the only open Dependabot alert on this repo.1 The package is a dev dependency, so it affects anyone who runs the linter, not sites that run the plugin.

The fixed release needs version 2 of the Human Made coding standards, and those need PHP 8.2 to run. This PR also raises the plugin's own minimum PHP version to 8.2, so the plugin and its tooling require the same version.

What changed

  • The Human Made coding standards move from 1.x to 2.5, which brings in the patched WordPress Coding Standards 3.4.1.2 The Composer audit now reports no advisories.
  • Breaking: the plugin now requires PHP 8.2 or later. WordPress refuses to activate it on older PHP, and Composer refuses to install it there.3
  • The new standards add PSR-12 formatting rules. The code fixes are mechanical: no space before a return type colon, a space after function in closures, and no blank line before a class's closing brace. phpcbf applied all of them.
  • The static methods on Flags now say public. PHP already treated them as public, so callers see no change.
  • The admin bar file imports the Ajax namespace instead of the single function. This keeps the import order valid for both ordering rules in the new standards, which conflict for function imports.4

Test plan

  • The linter passes on PHP 8.2 with the new standards and the 8.2 compatibility target (exit 0).5
  • Every PHP file passes a syntax check.
  • composer validate passes and composer audit reports no advisories.
  • CI lints this PR once Lint PHP and report Composer package changes in CI #26 (Lint PHP and report Composer package changes in CI) is merged. This repo has no CI on master yet.

Not checked: I did not load the plugin in WordPress. Apart from the version bump, the diff changes formatting, adds visibility keywords that change nothing, and changes one namespaced function call.

Risk: a site on PHP older than 8.2 that updates the plugin can no longer activate it. Mention this in the release notes for the next version.

Merge #26 first. It switches CI to PHP 8.2, which this lock needs. #25 (Cookie scope) needs a rebase after this PR merges, because its new code uses the old return type spacing.

Footnotes

  1. wp-coding-standards/wpcs >= 0.14.1, < 3.4.1, alert 1 at https://github.com/humanmade/wp-flags/security/dependabot/1. ↩

  2. humanmade/coding-standards ^1.2 → ^2.5, and wp-coding-standards/wpcs 2.3.0 → 3.4.1. minimum-stability is still dev, so some sniff packages lock to dev branches, as squizlabs/php_codesniffer already did. ↩

  3. Requires PHP: 8.2 in the plugin.php header, "php": ">=8.2" in composer.json, testVersion 8.2- in phpcs.ruleset.xml, and config.platform.php pinned to 8.2. ↩

  4. PSR12.Files.FileHeader.IncorrectOrder wants class imports before function imports. PSR2R.Namespaces.UseInAlphabeticalOrder wants all imports in alphabetical order. The call is now Ajax\get_toggle_url() in inc/admin-bar.php. ↩

  5. vendor/squizlabs/php_codesniffer/bin/phpcs --standard=phpcs.ruleset.xml ./
    
    ↩

wp-coding-standards/wpcs 2.3.0 has a high-severity arbitrary code
execution advisory, fixed in 3.4.1. humanmade/coding-standards 1.x pins
WPCS 2.x, so move to 2.5, which needs WPCS 3. The new standards need
PHP 8.2 to run. The plugin still supports PHP 7.2: the ruleset's
testVersion still checks for it.

The new sniffs add PSR-12 rules. phpcbf applied most of the fixes. The
Flags methods get an explicit `public`, which is what PHP already
assumed, and admin-bar.php imports the Ajax namespace instead of the
function so its imports satisfy both ordering sniffs.

Co-Authored-By: Claude <noreply@anthropic.com>
@svandragt svandragt self-assigned this Oct 16, 2026
The lint toolchain already needs PHP 8.2, so raise the plugin's own
minimum to match: the plugin header, composer.json and the ruleset's
testVersion. Pin config.platform.php to 8.2 so dependency resolution
and local tool runs use the same PHP.

Co-Authored-By: Claude <noreply@anthropic.com>
@svandragt svandragt changed the title Update coding standards to fix the WPCS code execution advisory Fix the WPCS code execution advisory and require PHP 8.2 Oct 16, 2026
@svandragt
svandragt requested a review from tomjn October 16, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants