Skip to content

Test that deactivation does not create the plugin option - #101

Merged
jdevalk merged 9 commits into
developfrom
claude/fix-deactivation-autoload
Nov 18, 2026
Merged

jdevalk merged 9 commits into
developfrom
claude/fix-deactivation-autoload

Conversation

@jdevalk

@jdevalk jdevalk commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Stacked on #100. Retarget to develop once #100 is merged.

The deactivation fix itself (wp_set_option_autoload() instead of re-saving the unchanged option) has since been pushed to #100 directly in dc39856, so this PR no longer changes plugin code.

What is left is one extra test: the old update_option() call created option_optimizer with a value of false when the option did not exist. test_deactivation_does_not_create_the_plugin_option asserts the fixed routine leaves a missing option missing. The existing deactivation test also flushes the cache before reading the value back.

Run locally on PHP 8.4 with WP 7.1.4, single and multisite: 53 tests pass. composer check-cs and composer phpstan pass.

🤖 Generated with Claude Code

jdevalk and others added 6 commits November 18, 2026 12:12
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>
The deactivation routine called update_option() with the value it had just read.
update_option() returns early when the value is unchanged, so the autoload flag
was never touched and option_optimizer stayed autoloaded after deactivation. When
the option was missing, the same call created it with a value of false.

Use wp_set_option_autoload() (WP 6.4+, the plugin requires 6.7), which changes
only the flag and does nothing when the option does not exist.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Plugin readme preview

Open preview · Commit 60a1697

29 passed · 1 warning · 0 notes

Warnings

  • “Tested up to” is 7.2; the latest WordPress major release is 7.1. Test with 7.1 and update the header.
Passed checks (29)
  • 76 / 150 characters in the short description.
  • Plugin name header recognized.
  • License header recognized: GPL-3.0-or-later.
  • 5 tags accepted within the five-tag limit.
  • Description is within the parser’s word limit.
  • Installation is within the parser’s word limit.
  • Faq is within the parser’s word limit.
  • Changelog is within the parser’s word limit.
  • Stable tag is declared: 1.7.1.
  • The PHP Version header is declared: 1.7.1.
  • Stable tag matches the PHP Version header: 1.7.1.
  • The readme “Requires at least” value is valid: 6.7.
  • The PHP “Requires at least” header is a numeric version: 6.7.
  • “Requires at least” matches between the readme and PHP header: 6.7.
  • The readme “Requires PHP” value is valid: 7.4.
  • The PHP “Requires PHP” header is a numeric version: 7.4.
  • “Requires PHP” matches between the readme and PHP header: 7.4.
  • “Tested up to” 7.2 meets the minimum WordPress version 6.7.
  • Installation content is present.
  • FAQ content is present.
  • Changelog content is present.
  • Screenshot captions are present.
  • The first changelog release matches Stable tag: 1.7.1.
  • The first changelog release matches PHP Version: 1.7.1.
  • Banner image loaded.
  • Plugin icon loaded.
  • Screenshot 1 has a matching image and caption.
  • Screenshot 2 has a matching image and caption.
  • Plugin PHP header loaded.

Readme and PHP-header checks only; this does not test plugin runtime compatibility.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Test on Playground
Test this pull request on the Playground
or download the zip

ilicfilip and others added 2 commits November 18, 2026 13:41
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>
The base branch now carries the same wp_set_option_autoload() fix. Keep its
version of the code and test, plus the extra test for a missing option.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jdevalk jdevalk changed the title Stop autoloading the plugin option on deactivation Test that deactivation does not create the plugin option Nov 18, 2026
Base automatically changed from claude/ci-workflow-gaps-3a5ea7 to develop November 18, 2026 13:01
#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
jdevalk merged commit 98eb683 into develop Nov 18, 2026
12 checks passed
@jdevalk
jdevalk deleted the claude/fix-deactivation-autoload branch November 18, 2026 13:05
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