Skip to content

Fix: improve rejected pages config handling - #1025

Open
kraftbj wants to merge 7 commits into
trunkfrom
cherry-pick/487-rejected-pages-improvements
Open

kraftbj wants to merge 7 commits into
trunkfrom
cherry-pick/487-rejected-pages-improvements

Conversation

@kraftbj

@kraftbj kraftbj commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cherry-picks the still-relevant changes from closed PR #487 ("Improve wp-cache config functions"), adapted to the current codebase.

Originally proposed by @stodorovic in #487.

Changes to wp_cache_update_rejected_pages() (now in inc/settings-forms.php):

  • Improved regex for config replacement: The regex now handles both single-quoted and double-quoted array keys in the config file ($wp_cache_pages['search'] and $wp_cache_pages["search"]), with any spacing, preventing stale entries when the quote style in the config doesn't match the hardcoded pattern.
  • Read checkbox values with empty(): A posted 0 or empty value now saves as 0 instead of 1.
  • Add an integration test that seeds a config with a single-quoted and an unspaced line and checks both are rewritten in place. It fails against the old regex.

The nonce handling from #487 isn't included. Both callers already set $valid_nonce before calling this function (the settings page from the same wp-cache nonce, the REST endpoint to true), so an inline check couldn't change the result.

See #487

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates how rejected page-type caching settings are persisted to the WP Super Cache config, improving config line matching and making nonce verification explicit within wp_cache_update_rejected_pages().

Changes:

  • Updates wp_cache_update_rejected_pages() to verify the nonce inline via wp_verify_nonce() and removes the $valid_nonce global dependency.
  • Enhances the config replacement regex so it matches both single-quoted and double-quoted $wp_cache_pages[...] keys when updating wp-cache-config.php.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wp-cache.php Resolved
@kraftbj
kraftbj force-pushed the cherry-pick/487-rejected-pages-improvements branch from e023a4f to 8b6daef Compare April 7, 2026 22:03
@kraftbj
kraftbj requested a review from donnchawp April 7, 2026 22:19
…cted-pages-improvements

# Conflicts:
#	wp-cache.php
Trunk moved wp_cache_update_rejected_pages() out of wp-cache.php, so the
merge took trunk's wp-cache.php. Apply the same change where the function
now lives.
Both callers set $valid_nonce first: the settings page from the same
wp-cache nonce, and the REST endpoint to true. The second check could
never change the result.
@kraftbj kraftbj changed the title Fix: improve rejected pages config handling and nonce verification Fix: improve rejected pages config handling Nov 11, 2026
@kraftbj
kraftbj marked this pull request as ready for review November 11, 2026 21:28
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.

3 participants