Skip to content

fix: read options from the same store they are saved to on multisite - #149

Open
superdav42 wants to merge 2 commits into
masterfrom
feature/auto-20261110-164336-2132872
Open

superdav42 wants to merge 2 commits into
masterfrom
feature/auto-20261110-164336-2132872

Conversation

@superdav42

@superdav42 superdav42 commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On multisite, when the plugin is not network-activated, settings were saved to the per-site wp_N_options table but always read with get_site_option(), which returns the network-level value. Sub-sites therefore saved their settings, never saw them again, and fell back to defaults (or to the primary site's values once it was configured).

Reported at https://wordpress.org/support/topic/multi-log-config/

Changes

  • includes/Options.php: get_options() now reads from the same store update_options() writes to: network option when network-activated, per-site option otherwise.
  • The static options cache is keyed by blog ID, so switch_to_blog() cannot return another site's cached settings.
  • readme.txt: changelog entry.

Verification

Ran the real Options class against a local multisite (plugin not network-active), saving timer=17 on blog 4 and then forcing a fresh read:

  • Before: re-read returned 5 (reproduces the report).
  • After: re-read returned 17; blogs 5 and 1 stayed at the default 5.
  • composer lint (PHPCS/PHPStan) and npm run lint pass with no errors.

Not run: the PHPUnit suite (needs a disposable _test database) and browser testing. The existing multisite test bootstrap network-activates the plugin, so it exercises only the network path; no new test added.


aidevops.sh v3.39.147 plugin for OpenCode

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where subsites that aren’t network-activated could show default settings instead of their own saved settings. Multisite settings now display and apply consistently with the values saved for each site. This helps ensure configuration changes are reflected correctly across multisite installations.

@superdav42 superdav42 added the origin:interactive Created by interactive user session label Nov 10, 2026
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The options getter now invalidates cached options when the current blog changes. It reads from site options on multisite and regular options otherwise. The Unreleased changelog records the multisite settings fix.

Changes: Multisite options

Layer / File(s) Summary
Blog-aware options retrieval
includes/Options.php, readme.txt
The getter clears cached options when the blog ID changes and selects the option store based on multisite status. The changelog notes that non-network-activated subsites use and display their own settings.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: ronalfy

Merge Risk: Minimal · up to b47a9

Site and network activations use matching settings stores. No merge-blocking issue was established.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: reading multisite options from the same store used to save them.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 1 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9e04d79 and b47a960.

Files selected for processing: 2

  • includes/Options.php
  • readme.txt

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@superdav42
superdav42 marked this pull request as ready for review November 11, 2026 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant