Skip to content

Ref. AntiCrawler. Module flow refactored.#788

Open
alexandergull wants to merge 1 commit intodevfrom
anti-crawler-ref.ag
Open

Ref. AntiCrawler. Module flow refactored.#788
alexandergull wants to merge 1 commit intodevfrom
anti-crawler-ref.ag

Conversation

@alexandergull
Copy link
Copy Markdown
Member

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 18, 2026

Codecov Report

❌ Patch coverage is 16.93122% with 157 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.42%. Comparing base (0132ded) to head (6232bae).
⚠️ Report is 6 commits behind head on dev.

Files with missing lines Patch % Lines
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php 16.66% 155 Missing ⚠️
cleantalk.php 0.00% 2 Missing ⚠️

❌ Your patch check has failed because the patch coverage (16.93%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev     #788      +/-   ##
============================================
- Coverage     14.46%   14.42%   -0.04%     
- Complexity     5543     5563      +20     
============================================
  Files           263      263              
  Lines         27231    27302      +71     
============================================
  Hits           3939     3939              
- Misses        23292    23363      +71     

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the AntiCrawler firewall module flow and renames/extracts UA blacklist table maintenance helpers, aligning SFW update code to the new AntiCrawler API.

Changes:

  • Renamed/extracted UA blacklist import & truncate helpers (updateUADataTable(), clearUADataTable()) and updated callers.
  • Refactored AntiCrawler::check() into clearer pre-check + log-check subroutines and added module constants/debug helper.
  • Renamed AntiCrawler log cleanup method to clearLogTable() and updated cron caller.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/Cleantalk/ApbctWP/Firewall/SFWUpdateHelper.php Switches UA list processing to AntiCrawler::updateUADataTable().
lib/Cleantalk/ApbctWP/Firewall/AntiCrawler.php Major AntiCrawler flow refactor; adds UA table helpers, cookie/param constants, debug helper, and method renames.
cleantalk.php Updates SFW update stage to use clearUADataTable() and cron cleanup to use clearLogTable().
Comments suppressed due to low confidence (2)

lib/Cleantalk/ApbctWP/Firewall/SFWUpdateHelper.php:66

  • processUA() checks !empty($result['error']) before verifying that $result is an array. On success AntiCrawler::updateUADataTable() returns an int, so this will trigger a PHP warning (array offset on int). Check is_array($result) (or isset($result['error'])) before reading the 'error' key, or normalize updateUADataTable() to always return an array structure.
        $result = AntiCrawler::updateUADataTable($file_path);

        if ( ! empty($result['error']) ) {
            return array('error' => 'UPDATING UA LIST: ' . $result['error']);
        }

        if ( ! is_int($result) ) {
            return array('error' => 'UPDATING UA LIST: : WRONG_RESPONSE AntiCrawler::update');

cleantalk.php:1592

  • AntiCrawler::clearUADataTable() returns void/null on success, but this code immediately reads $result__clear_db['error'], which will raise a PHP warning when the call succeeds (array offset on null). Either make clearUADataTable() return a consistent array result (e.g. [] on success), or guard with is_array($result__clear_db) before accessing ['error'].
    $result__clear_db = AntiCrawler::clearUADataTable(
        \Cleantalk\ApbctWP\DB::getInstance(),
        APBCT_TBL_AC_UA_BL
    );

    if ( ! empty($result__clear_db['error']) ) {
        return $result__clear_db['error'];
    }

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

"<script>
window.addEventListener('DOMContentLoaded', function () {
ctSetCookie( 'wordpress_apbct_antibot', '" . hash('sha256', $apbct->api_key . $apbct->data['salt']) . "', 0 );
ctSetCookie( " . self::COOKIE_NAME__ANTIBOT . ", '" . hash('sha256', $apbct->api_key . $apbct->data['salt']) . "', 0 );
Comment on lines +899 to +903
if ( is_array($data) ) {
$data = ' ' . print_r($data, true);
} else {
$data = '';
}
Comment on lines +893 to +894
private function debug(string $message, $data = null, $add_counstructor_data = false)
{
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