Skip to content

Tests: Cover notoptions after a failed option read - #1

Merged
gunjanjaswal merged 1 commit into
gunjanjaswal:fix/61762-notoptions-cache-db-errorsfrom
AceMedia:ticket/61762-notoptions-tests
Oct 21, 2026
Merged

gunjanjaswal merged 1 commit into
gunjanjaswal:fix/61762-notoptions-cache-db-errorsfrom
AceMedia:ticket/61762-notoptions-tests

Conversation

@AceMedia

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/61762

This builds on @gunjanjaswal's work in WordPress#12595 and is based on its exact head (f827e6a). I have not changed any production code. It adds a single commit of extra regression tests next to the ones already in the PR.

The existing tests check that notoptions is not written after a failed query. These add the "next request" angle, which is the actual harm with a persistent object cache. Each test simulates a request boundary by flushing the cache and restoring only the persisted notoptions entry, then asserts the option is still returned.

New tests:

  • option.php: a failed get_option() read, and a failed delete_option(), do not hide the option on the next request.
  • networkOption.php (multisite only): a failed get_network_option() read on a second network does not touch that network's notoptions or the main network's {network_id}:notoptions entry in the site-options group, while a genuine miss on the main network is still cached under its own key. A failed network read also does not hide the option on the next request.

Testing:

  • PHP 8.4.25, MariaDB 10.11.18, PHPUnit 9.6.35, run on PR head plus this commit.
  • tests/phpunit/tests/option/option.php: 90 tests, 140 assertions, 3 skipped (existing skips), single site and multisite.
  • tests/phpunit/tests/option/networkOption.php: 27 tests single site (network tests skipped as ms-required), 37 tests multisite.
  • Against the trunk base without the PR's production change, the new option.php tests (2) fail, and the 2 new multisite network tests that exercise a failed read fail.
  • I dropped a network delete test because it passes without the PR too, so it proves nothing.
  • Limits: the persistent cache is simulated with the default in-memory test cache, not a real Redis or Memcached drop-in. Failures are induced by rewriting the query to hit a missing table, not a genuine connection loss. Only MariaDB was used.
  • phpcs and php -l are clean on both files.

AI assistance: Codex and Claude helped me investigate, write the tests and run the checks. I have reviewed the code myself. The test results are from automated runs executed by the assistants.

Adds regression tests on top of the existing coverage for the notoptions fix. Each one simulates the next request of a persistent object cache by flushing the cache and restoring only the persisted `notoptions` entry, so a false "missing" marker written after a failed query would hide an option that still exists. Also checks that a failed network option read on one network does not touch another network's `{network_id}:notoptions` entry in the `site-options` group.

Follow-up to the work on #61762.

See https://core.trac.wordpress.org/ticket/61762.
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props shanerounce.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@gunjanjaswal
gunjanjaswal merged commit 21a4ec2 into gunjanjaswal:fix/61762-notoptions-cache-db-errors Oct 21, 2026
3 checks passed
@gunjanjaswal

Copy link
Copy Markdown
Owner

Thanks, these are good — the next-request angle is exactly the harm that matters with a persistent object cache, and the per-network isolation case is a nice touch. Rebased onto the PR branch so your authorship is preserved, and added props to you on the PR. Ran the full option + networkOption suites locally and everything passes. Appreciate the contribution.

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