Skip to content

Ref. Cookie. Removing unnecessary code - #865

Merged
AntonV1211 merged 3 commits into
devfrom
gfa_check_av
Aug 24, 2026
Merged

Ref. Cookie. Removing unnecessary code#865
AntonV1211 merged 3 commits into
devfrom
gfa_check_av

Conversation

@AntonV1211

Copy link
Copy Markdown
Contributor

@AntonV1211 AntonV1211 changed the title Gfa check av Ref. Cookie. Removing unnecessary code Aug 24, 2026
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 29.19%. Comparing base (59767a2) to head (cb0e3b5).
⚠️ Report is 1 commits behind head on dev.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AntonV1211
AntonV1211 requested review from Glomberg and a lite review from Copilot August 24, 2026 11:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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()/exit statements after wp_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.

Comment thread lib/Cleantalk/ApbctWP/Variables/AltSessions.php
@AntonV1211
AntonV1211 merged commit 4624eea into dev Aug 24, 2026
11 checks passed
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