Ref. Cookie. Removing unnecessary code - #865
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #865 +/- ##
============================================
- Coverage 29.20% 29.19% -0.01%
- Complexity 6443 6446 +3
============================================
Files 287 287
Lines 26064 26054 -10
============================================
- Hits 7611 7607 -4
+ Misses 18453 18447 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR removes redundant/unused request-termination and cookie-handling logic around “visible fields” and various AJAX-style responses, and adds a small hardening tweak for cross-platform path checks when reading local CSS.
Changes:
- Simplifies visible-fields retrieval by dropping native-cookie parsing in favor of POST-provided hidden field data.
- Removes multiple redundant
die()/exitstatements afterwp_send_json*()calls. - Normalizes directory separators before ABSPATH-prefix checks when resolving local CSS files.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/Cleantalk/ApbctWP/Variables/Cookie.php | Stops attempting to build visible-fields collections from native cookies; relies on POST hidden field instead. |
| lib/Cleantalk/ApbctWP/Variables/AltSessions.php | Removes some dead/duplicative termination and fallback assignments around JSON handling. |
| lib/Cleantalk/ApbctWP/ContactsEncoder/Integrations/CEIntegrationGridBuilder.php | Normalizes path separators before strpos ABSPATH-prefix validation. |
| lib/Cleantalk/Antispam/Integrations/UserRegistrationPro.php | Removes redundant die() and psalm-suppression noise after JSON response. |
| lib/Cleantalk/Antispam/Integrations/SureForms.php | Removes redundant die() after JSON error response. |
| lib/Cleantalk/Antispam/Integrations/MailPoet.php | Removes redundant die() after JSON response. |
| lib/Cleantalk/Antispam/Integrations/HivePressRegistration.php | Removes redundant die() after JSON response. |
| lib/Cleantalk/Antispam/Integrations/HivePress.php | Removes redundant die() after JSON response. |
| lib/Cleantalk/Antispam/Integrations/ElementorUltimateAddonsRegister.php | Removes redundant return after JSON response. |
| lib/Cleantalk/Antispam/Integrations/ChatyContactForm.php | Removes redundant exit after JSON response. |
| inc/cleantalk-public-integrations.php | Removes redundant exit (and related comment) after wp_send_json(). |
| inc/cleantalk-ajax.php | Removes redundant die() after wp_send_json_error() in an AJAX handler branch. |
Suppressed comments (3)
lib/Cleantalk/ApbctWP/Variables/AltSessions.php:204
- After wp_send_json() on nonce verification failure, add an explicit return so this method cannot proceed to mutate sessions when the nonce is invalid (and to keep static analysis/control flow clear).
if ( ! wp_verify_nonce($nonce, $action) ) {
wp_send_json(
array(
'success' => false,
'error' => 'AltSessions: Nonce verification failed. Please reload the page and try again.'
)
);
}
lib/Cleantalk/ApbctWP/Variables/AltSessions.php:217
- In the json_decode exception handler, add a return after wp_send_json(). Without it, $cookies_array may be undefined if execution continues, and later logic may run unexpectedly.
try {
$cookies_array = json_decode($cookies_to_set, true);
} catch ( \Exception $e ) {
unset($e);
wp_send_json(array(
'success' => false,
'error' => 'AltSessions: Internal JSON error:' . json_last_error_msg()));
}
lib/Cleantalk/ApbctWP/Variables/AltSessions.php:238
- After sending the JSON error for a null decoded cookies array, add a return so the method cannot continue into the foreach with $cookies_array === null.
if ( is_null($cookies_array) ) {
wp_send_json(array(
'success' => false,
'error' => 'AltSessions: Internal JSON error: $cookies_array is null.'));
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
https://app.doboard.com/1/task/41208