Repository navigation
Conversation
Ported from #79: the aaa_option_optimizer_protected_options filter lets other code add option names that can't be deleted, created with a false value, or have their autoload state changed through the plugin. Unlike the #79 version, the filter can only add names. Removing a built-in name has no effect, and a return value that is not an array of strings is ignored, so a broken callback can't switch off the built-in protection. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
12 tasks
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 |
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.
Ports the one piece of #79's protected-options work that
developdid not get from #93: theaaa_option_optimizer_protected_optionsfilter.What it does
Other code (an MU plugin, for example) can add option names to the protected list. Those options then can't be deleted, created with a false value, or have their autoload state changed through this plugin, and the list routes flag them so the admin screen hides the actions. Names match case-insensitively, like the built-in ones.
Difference from #79
In #79 the filter received the full list and its return value replaced it, so a callback could remove
siteurlfrom protection. Here the filter is add-only: removing a built-in name has no effect, and a return value that is not an array of non-empty strings is ignored. A broken callback can't switch the built-in protection off.The filter runs on each lookup rather than being cached, matching how the roles and theme-mods names are already added per call, so a filter added later in the request still applies.
Tests
Two new PHPUnit tests: a filtered name is refused by single delete, bulk delete and autoload change and is flagged in
all-options; and__return_empty_array,__return_falseand a list of non-strings all leavesiteurlprotected.Run locally: 59 tests pass on PHP 8.4 with WP 7.1.4 (single and multisite) and on PHP 7.4 with WP 6.7.
tests/hardening.php,composer check-cs,composer phpstanandcomposer lintpass.🤖 Generated with Claude Code