Skip to content

Fix. ContactEncoder. Improve shortcode statement. - #863

Merged
svfcode merged 2 commits into
fixfrom
upd-ce4
Aug 20, 2026
Merged

Fix. ContactEncoder. Improve shortcode statement.#863
svfcode merged 2 commits into
fixfrom
upd-ce4

Conversation

@svfcode

@svfcode svfcode commented Aug 20, 2026

Copy link
Copy Markdown
Member

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.48649% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.52%. Comparing base (0c2da87) to head (c3f5252).

Files with missing lines Patch % Lines
...sEncoder/Integrations/CEIntegrationCommentList.php 88.40% 8 Missing ⚠️
...P/ContactsEncoder/Shortcodes/ShortCodesService.php 60.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                fix     #863      +/-   ##
============================================
+ Coverage     29.36%   29.52%   +0.16%     
- Complexity     6467     6493      +26     
============================================
  Files           288      289       +1     
  Lines         26126    26199      +73     
============================================
+ Hits           7672     7736      +64     
- Misses        18454    18463       +9     

☔ 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.

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 updates the Contacts Encoder buffer-mode shortcode handling to avoid processing/“absorbing” content inside rendered WordPress comment lists, and adds PHPUnit coverage for the new behavior.

Changes:

  • Added CEIntegrationCommentList to protect/restore rendered comment list regions during buffer-mode processing.
  • Integrated the new comment-list protection into ShortCodesService::modifyBufferBefore() / modifyBufferAfter().
  • Added/extended tests to validate comment list preservation and buffer-mode behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/Cleantalk/ApbctWP/ContactsEncoder/Shortcodes/ShortCodesService.php Wraps buffer processing with comment-list protect/restore to prevent unintended shortcode handling inside comments.
lib/Cleantalk/ApbctWP/ContactsEncoder/Integrations/CEIntegrationCommentList.php New integration that replaces detected comment-list HTML regions with placeholders and later restores them.
tests/ApbctWP/ContactsEncoder/TestContactsEncoderShortCodeEncode.php Adds a buffer-mode regression test ensuring comment text and encode_data tags aren’t incorrectly processed.
tests/ApbctWP/ContactsEncoder/Integrations/TestCEIntegrationCommentList.php Adds unit tests for protect/restore correctness and no-op behavior when no comment list is present.
Suppressed comments (1)

lib/Cleantalk/ApbctWP/ContactsEncoder/Integrations/CEIntegrationCommentList.php:52

  • restore() keeps $region_placeholders populated after it runs, which retains the full protected comment HTML in memory and keeps state around for subsequent calls. Clear the placeholders after applying strtr() (similar to CEIntegrationGridBuilder::restoreRegions() which resets its placeholders).
    public function restore($content)
    {
        if ( ! is_string($content) || $this->region_placeholders === array() ) {
            return $content;
        }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (1)

lib/Cleantalk/ApbctWP/ContactsEncoder/Integrations/CEIntegrationCommentList.php:24

  • CEIntegrationCommentList keeps state in $region_placeholders. In protect(), the placeholders are only reset after the early substring checks; if the same instance previously protected content and later protect() returns early (no comment markers), a subsequent restore() can still apply stale placeholder replacements to unrelated content. Reset placeholders at the start of protect() (before any early returns).
    public function protect($content)
    {
        if ( ! is_string($content) || $content === '' ) {
            return $content;
        }

@svfcode
svfcode merged commit 95ac965 into fix Aug 20, 2026
7 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.

2 participants