Plugin Directory

Changeset 3436960


Ignore:
Timestamp:
01/11/2026 08:24:31 AM (3 months ago)
Author:
winrid
Message:

3.16.2 - Initial sync and other theme/plugin compatibility improvements with regards to blocking spam

Location:
fastcomments
Files:
40 added
4 edited

Legend:

Unmodified
Added
Removed
  • fastcomments/trunk/README.txt

    r3380398 r3436960  
    33Tags: live comments, comments, comment spam, comment system, fast comments, live commenting
    44Requires at least: 4.6
    5 Tested up to: 6.8.3
    6 Stable tag: 3.16.1
     5Tested up to: 6.9.1
     6Stable tag: 3.16.2
    77Requires PHP: 5.2.5
    88License: GPLv2 or later
     
    8888== Changelog ==
    8989
     90= 3.16.2 =
     91* Improved initial sync reliability
     92* Further improvements to prevent bots from submitting spam around the plugin, but in a way that interferes with other themes/plugins less.
     93
    9094= 3.16.1 =
    9195* Prevent bots from submitting spam directly to the WP endpoint when the plugin is installed
  • fastcomments/trunk/core/FastCommentsIntegrationCore.php

    r2771905 r3436960  
    143143            $domainName = $this->getDomain();
    144144            $rawTokenUpsertResponse = $this->makeHTTPRequest('PUT', "$this->baseUrl/token?token=$token&integrationType=$this->integrationType&domain=$domainName", null);
     145
     146            if ($rawTokenUpsertResponse->responseStatusCode !== 200) {
     147                $this->log('warn', "Token validation HTTP request failed with status code: {$rawTokenUpsertResponse->responseStatusCode}");
     148                return null;
     149            }
     150
     151            if (empty($rawTokenUpsertResponse->responseBody)) {
     152                $this->log('warn', "Token validation received empty response body");
     153                return null;
     154            }
     155
    145156            $tokenUpsertResponse = json_decode($rawTokenUpsertResponse->responseBody);
    146             if ($tokenUpsertResponse->status === 'success' && $tokenUpsertResponse->isTokenValidated === true) {
    147                 $this->setSettingValue('fastcomments_tenant_id', $tokenUpsertResponse->tenantId);
     157
     158            if ($tokenUpsertResponse === null) {
     159                $this->log('warn', "Token validation failed to parse JSON response: " . substr($rawTokenUpsertResponse->responseBody, 0, 200));
     160                return null;
     161            }
     162
     163            $status = isset($tokenUpsertResponse->status) ? $tokenUpsertResponse->status : 'unknown';
     164            $isValidated = isset($tokenUpsertResponse->isTokenValidated) ? $tokenUpsertResponse->isTokenValidated : false;
     165            $tenantId = isset($tokenUpsertResponse->tenantId) ? $tokenUpsertResponse->tenantId : null;
     166
     167            $this->log('debug', "Token validation response: status={$status} isTokenValidated=" . var_export($isValidated, true) . " tenantId=" . var_export($tenantId, true));
     168
     169            if ($status === 'success' && $isValidated === true && !empty($tenantId)) {
     170                $this->setSettingValue('fastcomments_tenant_id', $tenantId);
    148171                $this->setSettingValue('fastcomments_token_validated', true);
     172                $this->log('info', "Token validated successfully, tenant_id set to {$tenantId}");
     173            } else if ($status === 'success' && $isValidated === true) {
     174                $this->log('warn', "Token validated but tenantId was empty/null - not setting tenant_id");
     175            } else if ($status === 'success' && $isValidated === false) {
     176                $this->log('debug', "Token not yet validated by user on FastComments side");
     177            } else {
     178                $this->log('warn', "Token validation got unexpected response - status: {$status}, isValidated: " . var_export($isValidated, true));
    149179            }
    150180            return null;
  • fastcomments/trunk/core/FastCommentsWordPressIntegration.php

    r2771905 r3436960  
    236236
    237237    public function makeHTTPRequest($method, $url, $body) {
     238        // Use longer timeout for POST requests (comment uploads can take time with large batches)
     239        $timeout = ($method === 'POST' && $body) ? 60 : 20;
    238240        $rawResult = wp_remote_request($url, array(
    239241            'method' => $method,
    240242            'body' => $body,
    241             'timeout' => 20,
     243            'timeout' => $timeout,
    242244            'headers' => array('Content-Type' => 'application/json; charset=utf-8'),
    243245            'data_format' => $body ? 'body' : 'query'
     
    365367        $fc_comment['comment'] = $wp_comment->comment_content ? $wp_comment->comment_content : '';
    366368        $fc_comment['externalParentId'] = $wp_comment->comment_parent ? $wp_comment->comment_parent : null; // 0 is the WP default (no parent). we can't do anything with 0.
    367         $fc_comment['date'] = $wp_comment->comment_date;
     369        $fc_comment['date'] = $wp_comment->comment_date_gmt ? $wp_comment->comment_date_gmt : $wp_comment->comment_date;
    368370        $fc_comment['votes'] = $votes;
    369371        $fc_comment['votesUp'] = $votes > 0 ? $votes : 0;
  • fastcomments/trunk/fastcomments-wordpress-plugin.php

    r3380398 r3436960  
    33Plugin Name: FastComments
    44Plugin URI: https://fastcomments.com
    5 Description: A live, fast, privacy-focused commenting system.
    6 Version: 3.16.1
     5Description: A live, fast, privacy-focused commenting system with advanced spam prevention capabilities.
     6Version: 3.16.2
    77Author: winrid @ FastComments
    88License: GPL-2.0+
     
    1414}
    1515
    16 $FASTCOMMENTS_VERSION = 3.161;
     16$FASTCOMMENTS_VERSION = 3.162;
    1717
    1818require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php';
     
    9494
    9595    // Prevent spam bots from submitting to WordPress's native comment endpoints
    96     add_filter('comments_open', 'fc_block_native_comments', 10, 2);
     96    add_action('pre_comment_on_post', 'fc_block_native_submissions');
    9797    add_filter('rest_pre_insert_comment', 'fc_block_rest_comments', 10, 2);
    9898}
    9999
    100100// Block submissions to wp-comments-post.php
    101 function fc_block_native_comments($open, $post_id) {
    102     // When FastComments is active, close native WordPress comments to prevent bot spam
     101function fc_block_native_submissions($comment_post_ID) {
     102    // When FastComments is active, block native WordPress comment submissions
    103103    if (get_option('fastcomments_tenant_id')) {
    104         return false;
     104        wp_die(__('Comments must be submitted through FastComments.', 'fastcomments'), __('Comments Disabled', 'fastcomments'), array('response' => 403));
    105105    }
    106     return $open;
    107106}
    108107
     
    122121function fastcomments_cron()
    123122{
    124     require_once plugin_dir_path(__FILE__) . 'core/FastCommentsWordPressIntegration.php';
    125     $fastcomments = new FastCommentsWordPressIntegration();
    126     $fastcomments->log('debug', 'Begin cron tick.');
    127     $fastcomments->tick();
    128     $fastcomments->log('debug', 'End cron tick.');
     123    try {
     124        require_once plugin_dir_path(__FILE__) . 'core/FastCommentsWordPressIntegration.php';
     125        $fastcomments = new FastCommentsWordPressIntegration();
     126        $fastcomments->log('debug', 'Begin cron tick.');
     127        $fastcomments->tick();
     128        $fastcomments->log('debug', 'End cron tick.');
     129    } catch (Exception $e) {
     130        error_log('ERROR:::FastComments cron failed: ' . $e->getMessage());
     131    }
    129132}
    130133
Note: See TracChangeset for help on using the changeset viewer.