Repository navigation
Add PHPUnit, Plugin Check, JS/CSS lint and image compression workflows - #100
Merged
Merged
Conversation
Sets up PHPUnit the way fewer-tags and comment-experience do: yoast/wp-test-utils, tests/bin/install-wp-tests.sh and `composer test`. The lock file is resolved for PHP 7.4 (config.platform.php), the lowest version the plugin supports. The first suite (52 tests) covers the tracking table, option access tracking, activation/deactivation, the known-plugins mapping, and the REST routes that change or delete options, including the capability and nonce checks. test.yml runs it on PHP 7.4/WP 6.7, PHP 8.2/WP latest and PHP 8.4/WP latest multisite. PHPStan now also skips node_modules, which holds PHP files after `npm ci`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`npm run lint:css` could not run at all: the root @wordpress/stylelint-config ^22 pulled in stylelint 14, while @wordpress/scripts 30 ships a config that needs stylelint 16. Drop the redundant root config (wp-scripts brings its own) and depend on stylelint 16 directly. Apply the auto-fixes (whitespace, `bold` to `700`, one Prettier line join) and baseline the two no-descending-specificity findings, since reordering those rules would change the cascade. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copied from comment-experience/brand-assets, with every action pinned to a commit SHA. It checks the same file set that is deployed (wp dist-archive + .distignore). Add the direct file access guard to src/autoload.php, the one error Plugin Check reports. The remaining findings are warnings and do not fail the check. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
calibreapp/image-actions, as in brand-assets, limited to images under .wordpress-org and to pull requests from this repository. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The file has been empty since the playground logic moved into playground.yml, which comments on every pull request. GitHub can't parse an empty workflow, so each push recorded a failed run. Same change as #96. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Plugin readme previewOpen preview · Commit 29 passed · 1 warning · 0 notes Warnings
Passed checks (29)
Readme and PHP-header checks only; this does not test plugin runtime compatibility. |
|
Test on Playground |
Composer package changes
|
Deactivation re-saved the unchanged option with update_option(), which returns before touching autoload, so the option stayed autoloaded. Use wp_set_option_autoload() and assert it in the test. The two REST tests created their admin user before batch_insert(), whose COMMIT made the user (and the multisite super admin grant) permanent. Create the user after the commit so it is rolled back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ilicfilip
approved these changes
Nov 18, 2026
ilicfilip
left a comment
Collaborator
There was a problem hiding this comment.
Pushed dc39856: deactivation now uses wp_set_option_autoload() because update_option() with an unchanged value never turned autoload off (the test now asserts it), and the two REST tests create their admin user after batch_insert() commits so the user is rolled back instead of leaking.
jdevalk
added a commit
that referenced
this pull request
Nov 18, 2026
#100 was squash-merged, so the branch needed develop's history. No content change beyond the extra deactivation test. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jdevalk
added a commit
that referenced
this pull request
Nov 18, 2026
…tions The REST tests from #100 asserted the old behaviour. Adjust them to the hardened routes: schema validation rejects unknown autoload values, missing options are reported as update_failed instead of 404 or being skipped silently, and the in-handler nonce checks are gone (core REST authentication checks cookie nonces). The admin page only pauses tracking for an administrator in wp-admin, so cover both that and the front-end case. Add tests for what the hardening introduces: protected options can't be deleted or have their autoload flag changed, a protected name refuses a whole batch, and malformed option names are rejected. Make js/admin-script.js pass the JS lint job that develop now has: Prettier formatting, eslint-disable comments moved to the lines they apply to, and the DataTable lookup moved after the early return. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
jdevalk
added a commit
that referenced
this pull request
Nov 18, 2026
* Harden option actions, tracking, and release workflows * Return raw stored option values without serializing again * Fix protected options, sort direction and CI pinning from #93 review - Protect the active theme's real theme_mods_{stylesheet} option instead of the non-existent "theme_mods"; inactive themes' leftovers stay removable. - Protect salts and keys WordPress stores in the database when wp-config.php doesn't define them. - Build the lowercased protected-name map once per request and resolve bulk collation aliases with a single IN query instead of one query per name. - Compare the sort direction case-insensitively again, as develop did. - Pin the new javascript-regressions job's actions to commit SHAs. - Fetch a full page in the list-response test so fixtures aren't paginated away on sites with more than 25 matching options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Rework tracking limits from #93 review The tracking-limited flag paused unused-option recommendations site-wide and only a manual reset cleared it, yet it was set by routine events: a 1s lock timeout under concurrent traffic, any request reading over 1,000 options, or a transient SQL error. Legacy migrations over 10,000 names could never finish, and pruning deleted the oldest (core) rows. - Drop the GET_LOCK serialisation; the 10,000-name cap is now a soft limit checked without a lock. No MySQL-only lock functions or DELETE ... LIMIT. - Set the flag only when a new name is actually dropped for capacity, or one request reads more names than storage holds. Write failures don't set it. - Detect existing names with a SQL join, so case/accent variants of a stored row count as existing, matching the primary key's collation. - Migrate legacy data without the cap so migration always completes. - Never prune rows, and don't truncate reads at the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the tracking table first in the existing-name join wpdb parses the first FROM to check the table charset for non-ASCII queries; a leading subquery made every at-capacity write with a non-ASCII name fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update the tracking-limited notice to the new trigger Write failures no longer pause recommendations, so the notice now names the only remaining cause: a full tracking table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Make the alias protection test independent of the database engine SQLite folds case but not accents, so 'sitéurl' is a distinct, unprotected option there; the test now only expects 403 where the engine maps the name to a protected row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Use an alias both MySQL and SQLite fold in the non-ASCII capacity test SQLite's case folding is ASCII-only, so vary only the ASCII letters; the name stays non-ASCII to keep exercising wpdb's charset check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Start the integration test from empty tracking data Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Update the PHPUnit suite and JS formatting for the hardened option actions The REST tests from #100 asserted the old behaviour. Adjust them to the hardened routes: schema validation rejects unknown autoload values, missing options are reported as update_failed instead of 404 or being skipped silently, and the in-handler nonce checks are gone (core REST authentication checks cookie nonces). The admin page only pauses tracking for an administrator in wp-admin, so cover both that and the front-end case. Add tests for what the hardening introduces: protected options can't be deleted or have their autoload flag changed, a protected name refuses a whole batch, and malformed option names are rejected. Make js/admin-script.js pass the JS lint job that develop now has: Prettier formatting, eslint-disable comments moved to the lines they apply to, and the DataTable lookup moved after the early return. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Filip Ilic <ilic.filip@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the CI gaps found in the workflow audit of 2026-11-18. One workflow file per concern, every action pinned to a commit SHA, minimal
permissions:.What's added
yoast/wp-test-utils,tests/bin/install-wp-tests.sh,composer test, and a first suite of 52 integration tests: the tracking table, option access tracking, activation, the known-plugins mapping, and the REST routes that flip autoload or delete options (including capability and nonce checks).test.yml— PHP 7.4 / WP 6.7, PHP 8.2 / WP latest, PHP 8.4 / WP latest multisite.plugin-check.yml— WordPress.org Plugin Check on thewp dist-archivebuild.js-css-lint.yml— runs the existinglint:jsandlint:cssscripts.image-actions.yml— compresses images under.wordpress-org, same-repo PRs only.playground-merged.ymlremoved — it was empty, so every push recorded a failed run.playground.ymlalready comments on every PR. Same change as Remove the empty playground-merged.yml workflow #96.Changes outside the workflows
composer.json:config.platform.phpset to 7.4.33 so the lock stays installable on the lowest supported PHP. The lock only gained packages; no existing version moved.package.json:lint:csscould not run (root@wordpress/stylelint-config^22 pulled stylelint 14,@wordpress/scripts30 needs 16). Removed the root config and addedstylelint^16.css/style.css,js/admin-script.js: lint auto-fixes only (whitespace,boldto700, one line join). Twono-descending-specificityfindings are baselined.src/autoload.php:ABSPATHguard, the one error Plugin Check reported. Same hunk as in Harden option actions, tracking, and release workflows #93.phpstan.neon.dist: excludesnode_modules.Verified locally
composer teston PHP 8.4 with WP 7.1.4 (single and multisite) and WP 6.7, and on PHP 7.4 with WP 6.7.composer check-cs,phpstan,lint,npm run lint:js,npm run lint:css,actionlint.DirectDB.UnescapedDBParameterwarnings (these do not fail the check).Notes for review
aaa_option_optimizer_deactivation()does not actually turn off autoload foroption_optimizer:update_option()with an unchanged value returns early. Not fixed here; the test only asserts the value is kept.🤖 Generated with Claude Code