Skip to content

fix: isolate settings cache by network - #1745

Open
superdav42 wants to merge 1 commit into
mainfrom
fix/network-aware-settings-cache
Open

fix: isolate settings cache by network#1745
superdav42 wants to merge 1 commit into
mainfrom
fix/network-aware-settings-cache

Conversation

@superdav42

@superdav42 superdav42 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • associate the singleton settings cache with the network that loaded it
  • reload settings when WordPress changes network context
  • preserve cache ownership after both single-setting and full settings saves
  • add a regression test proving a save after a network switch preserves the target network's settings

Verification

  • Settings test suite: 55 tests, 83 assertions passed
  • PHP syntax checks passed
  • pre-commit PHPCS and PHPStan checks passed
  • git diff --check passed

aidevops.sh v3.32.291 plugin for OpenCode v1.18.25 with gpt-5.6-sol

Summary by CodeRabbit

  • Bug Fixes

    • Fixed settings cache handling when switching between network contexts.
    • Ensured settings are loaded from and saved to the correct network, preventing values from being carried over incorrectly.
  • Tests

    • Added coverage for saving settings after a network context change.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: c5411267-eaec-43fa-b5fb-cde5733c8753

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae7b0f and dc04ba1.

📒 Files selected for processing (2)
  • inc/class-settings.php
  • tests/WP_Ultimo/Settings_Test.php

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The Settings singleton now tracks the network ID associated with its cache. It reloads settings after network-context changes and records the active network after saves. A test verifies that saving after a switch updates only the target network.

Changes

Network-aware settings cache

Layer / File(s) Summary
Track and reload network-scoped settings
inc/class-settings.php
Settings stores the network ID for cached settings. get_all() reloads settings when the active network differs from the cached network.
Keep saved settings associated with the active network
inc/class-settings.php, tests/WP_Ultimo/Settings_Test.php
save_setting() and save_settings() update the cached network ID. The test verifies that a save after switching networks preserves target settings and excludes source-only data.

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

Merge Risk: ⚪ Minimal · up to dc04b

The change isolates settings caching by network and reloads settings when network context changes; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: isolating the settings cache by network.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/network-aware-settings-cache

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

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.

1 participant