Fix. Settings. ct_prev_referer cookie breaks page caching. - #71
Merged
Conversation
Move prev_referer to JS so PHP does not Set-Cookie on every pageview; give ct_cookies_test a 7-day TTL instead of a session cookie.
There was a problem hiding this comment.
Pull request overview
This PR adjusts how CleanTalk’s “previous referrer” and cookie-test probe cookies are set/read to avoid PHP-driven Set-Cookie updates that can disrupt page caching, and bumps the extension version to 5.8.1.
Changes:
- Set
ct_prev_refererfrom JS (document.referrer) instead of PHP, and read it from the unprefixed cookie name in spam checks. - Change
ct_cookies_testpayload and set an explicit lifetime (7 days). - Bump extension version from 5.8.0 to 5.8.1 in composer metadata and ACP module info.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cleantalk/antispam/styles/all/template/cleantalk.js | Adds JS-managed ct_prev_referer cookie on pageview. |
| cleantalk/antispam/model/main_model.php | Reads ct_prev_referer without phpBB prefix; revises cookie-test probe cookie behavior/lifetime. |
| cleantalk/antispam/composer.json | Version bump to 5.8.1. |
| cleantalk/antispam/acp/main_info.php | ACP module version bump to 5.8.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Only set ct_cookies_test when missing/invalid to avoid Set-Cookie on every hit; clear ct_prev_referer in JS when document.referrer is empty.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
cleantalk/antispam/model/main_model.php:308
- Early-return validation for an existing ct_cookies_test cookie only checks
check_value. If a client sends a malformed cookie that has the correctcheck_valuebut is missingcookies_names(or it’s not an array),set_cookie()will skip rewriting it, andtest_cookie()will later doforeach ($cookie_test['cookies_names'] ...), triggering warnings / incorrect behavior. Validate the cookie structure (includingcookies_namesbeing an array) before returning early.
if ( $this->request->is_set($cookie_key, \phpbb\request\request_interface::COOKIE) ) {
$existing = json_decode(htmlspecialchars_decode($this->request->variable($cookie_key, '', false, \phpbb\request\request_interface::COOKIE)), true);
if ( is_array($existing) && isset($existing['check_value']) && $existing['check_value'] === $expected ) {
return;
}
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.
task https://app.doboard.com/1/task/54234