fix(settings): keep wp_stream option autoload explicit#1936
Open
faisalahammad wants to merge 1 commit into
Open
fix(settings): keep wp_stream option autoload explicit#1936faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
- Pass true on update_option when writing per-site settings - Register setting with autoload true for the Settings API path - Repair stray no-autoload rows on admin_init via wp_set_option_autoload - Add unit tests for write path, repair, idempotency, and network no-op Settings load on every request for exclude rules, logging gates, and role access, so autoload stays on by design. Fixes xwp#1482
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.
Summary
The
wp_streamsettings option is loaded on every request (Plugin::init→Settings::__construct→get_options) for exclude rules, logging gates, and role access. Autoload must stay on; turning it off without lazy-loading would add aget_optionquery on every page load.This change makes that intent explicit on write paths and repairs any install whose row was flipped to no-autoload.
Fixes #1482
Changes
classes/class-settings.phpBefore:
After:
Why: New writes and Settings API saves keep autoload on. A one-shot admin repair covers existing installs that somehow ended up with autoload off. Network settings (
wp_stream_network/ sitemeta) are untouched.tests/phpunit/test-class-settings.phpWhy: Cover the write path, no→yes repair, idempotency, and network-key no-op.
Testing
Test 1: Fresh save keeps autoload on
wp db query "SELECT option_name, autoload FROM wp_options WHERE option_name = 'wp_stream'"Result:
autoloadisyes/on/auto-on.Test 2: Repair path
wp db query "UPDATE wp_options SET autoload = 'no' WHERE option_name = 'wp_stream'"Result:
autoloadis back in the yes-family.Test 3: Settings still work
Result: matching event not logged; non-matching event logged. No PHP notices.
Automated:
composer lint,composer lint-tests, PHPUnitTest_Settings(single-site + multisite) pass.