Plugin Directory

Changeset 2577475


Ignore:
Timestamp:
08/03/2021 10:34:26 PM (5 years ago)
Author:
winrid
Message:

3.9.3 - Bugfixes

Location:
fastcomments
Files:
34 added
4 edited

Legend:

Unmodified
Added
Removed
  • fastcomments/trunk/README.txt

    r2577451 r2577475  
    44Requires at least: 4.6
    55Tested up to: 5.8
    6 Stable tag: 3.9.2
     6Stable tag: 3.9.3
    77Requires PHP: 5.2.4
    88License: GPLv2 or later
     
    8585== Changelog ==
    8686
     87= 3.9.3 =
     88* Stability improvements and sync-related bugfixes.
     89
    8790= 3.9.2 =
    8891* Stability improvements and sync-related bugfixes. Initial setup made more intuitive in some areas.
  • fastcomments/trunk/core/FastCommentsIntegrationCore.php

    r2577451 r2577475  
    3838    public abstract function handleEvents($events);
    3939
    40     public abstract function getCommentCount();
     40    public abstract function getCommentCount($startFromDateTime);
    4141
    4242    public abstract function getComments($startFromDateTime);
     
    246246        $startedAt = time();
    247247        $hasMore = true;
    248         $countSyncedSoFar = $this->getSettingValue('fastcomments_comment_sent_count') ? $this->getSettingValue('fastcomments_comment_sent_count') : 0;
    249         $commentCount = $this->getCommentCount();
    250         if ($commentCount == 0) {
     248        if ($this->getCommentCount(0) == 0) {
    251249            $this->log('debug', 'No comments to send. Telling server.');
    252250            $requestBody = json_encode(
     
    261259            return;
    262260        }
    263         while ($hasMore && time() - $startedAt < 30 * 1000) {
     261//        while ($hasMore && time() - $startedAt < 30 * 1000) {
    264262            $this->log('debug', 'Send comments command loop...');
    265263            $getCommentsResponse = $this->getComments($lastSendDate ? $lastSendDate : 0);
     
    268266                $hasMore = $getCommentsResponse['hasMore'];
    269267                $this->log('info', "Got comments to send count=[$count] hasMore=[$hasMore]");
    270                 if ($getCommentsResponse['comments'] && count($getCommentsResponse['comments']) > 0) {
    271                     $countRemaining = max($commentCount - (count($getCommentsResponse['comments']) + $countSyncedSoFar), 0);
    272                     $requestBody = json_encode(
    273                         array(
    274                             "countRemaining" => $countRemaining,
    275                             "comments" => $getCommentsResponse['comments']
    276                         )
    277                     );
    278                     $httpResponse = $this->makeHTTPRequest('POST', "$this->baseUrl/comments?token=$token", $requestBody);
    279                     $this->log('debug', "Got POST /comments response status code=[$httpResponse->responseStatusCode]");
    280                     $response = json_decode($httpResponse->responseBody);
    281                     if ($response->status === 'success') {
    282                         $fromDateTime = strtotime($getCommentsResponse['comments'][count($getCommentsResponse['comments']) - 1]['date']) * 1000;
    283                         $lastSendDate = $fromDateTime;
    284                         $this->setSettingValue('fastcomments_stream_last_send_timestamp', $fromDateTime);
    285                         $countSyncedSoFar += count($getCommentsResponse['comments']);
    286                         $this->setSettingValue('fastcomments_comment_sent_count', $countSyncedSoFar);
    287                         if (!$hasMore || $countRemaining === 0) {
    288                             $this->setSetupDone();
    289                             break;
    290                         }
     268                $countRemaining = $getCommentsResponse['comments'] ? count($getCommentsResponse['comments']) : 0;
     269                if ($countRemaining > 0) {
     270                    $commentChunks = array_chunk($getCommentsResponse['comments'], 100);
     271                    foreach ($commentChunks as $chunk) {
     272                        $lastCommentFromDateTime = strtotime($chunk[count($chunk) - 1]['date']) * 1000;
     273                        $countRemaining -= count($chunk);
     274                        $requestBody = json_encode(
     275                            array(
     276                                "countRemaining" => $countRemaining,
     277                                "comments" => $chunk
     278                            )
     279                        );
     280                        $httpResponse = $this->makeHTTPRequest('POST', "$this->baseUrl/comments?token=$token", $requestBody);
     281                        $this->log('debug', "Got POST /comments response status code=[$httpResponse->responseStatusCode]");
     282                        $response = json_decode($httpResponse->responseBody);
     283//                        if ($response->status === 'success') {
     284                            $fromDateTime = $lastCommentFromDateTime;
     285                            $lastSendDate = $fromDateTime;
     286                            $this->setSettingValue('fastcomments_stream_last_send_timestamp', $fromDateTime);
     287                            if ($countRemaining <= 0) {
     288                                $this->setSetupDone();
     289                                break;
     290                            }
     291//                        }
    291292                    }
    292293                } else {
    293294                    $this->setSetupDone();
    294                     break;
     295//                    break;
    295296                }
    296297            } else {
     
    299300                $debugHasMore = $getCommentsResponse['hasMore'];
    300301                $this->log('error', "Failed to get comments to send: status=[$status] comments=[$comments] hasMore=[$debugHasMore]}");
    301                 break;
    302             }
    303         }
     302//                break;
     303            }
     304//        }
    304305        $this->log('debug', 'Done sending comments');
    305306    }
  • fastcomments/trunk/core/FastCommentsWordPressIntegration.php

    r2577451 r2577475  
    4242        global $FASTCOMMENTS_VERSION;
    4343
    44         if ((string) $FASTCOMMENTS_VERSION !== (string) $this->getSettingValue('fastcomments_version')) {
     44        if ((string)$FASTCOMMENTS_VERSION !== (string)$this->getSettingValue('fastcomments_version')) {
    4545            $is_old_version = !get_option('fc_fastcomments_comment_ids_version');
    4646            if ($is_old_version) {
     
    224224
    225225        $wp_comment['comment_ID'] = is_numeric($wp_id) ? $wp_id : null;
    226         $wp_comment['comment_post_ID'] = (int) $fc_comment->urlId;
     226        $wp_comment['comment_post_ID'] = (int)$fc_comment->urlId;
    227227        $finalpostId = $wp_comment['comment_post_ID'];
    228228        $wp_comment['comment_post_url'] = $fc_comment->url;
     
    349349    }
    350350
    351     public function getCommentCount() {
    352         $count_result = wp_count_comments();
    353         return $count_result ? $count_result->total_comments : 0;
     351    public function getCommentCount($startFromDateTime) {
     352//        if (isset($startFromDateTime)) {
     353//            $args = array(
     354//                'date_query' => array(
     355//                    'after' => date('c', $startFromDateTime ? $startFromDateTime / 1000 : 0)
     356//                ),
     357//                'count' => true
     358//            );
     359//            $wp_comments_count = get_comments($args);
     360//            return $wp_comments_count;
     361//        } else {
     362            $count_result = wp_count_comments();
     363            return $count_result ? $count_result->total_comments : 0;
     364//        }
    354365    }
    355366
    356367    public function getComments($startFromDateTime) {
    357         $limit = 100;
     368//        $limit = 100;
    358369        $args = array(
    359             'number' => $limit + 1,
     370//            'number' => $limit + 1,
    360371            'date_query' => array(
    361372                'after' => date('c', $startFromDateTime ? $startFromDateTime / 1000 : 0),
    362373                'inclusive' => true
    363374            ),
    364             'orderby' => 'comment_date',
     375            'orderby' => array('comment_date', 'comment_ID'),
    365376            'order' => 'ASC'
    366377        );
    367378        $wp_comments = get_comments($args);
    368         $has_more = count($wp_comments) > $limit;
     379//        $has_more = count($wp_comments) > $limit;
     380        $has_more = false;
    369381        $fc_comments = array();
    370         for ($i = 0; $i < min(count($wp_comments), $limit); $i++) {
     382//        for ($i = 0; $i < min(count($wp_comments), $limit); $i++) {
     383        for ($i = 0; $i < count($wp_comments); $i++) {
    371384            array_push($fc_comments, $this->wp_to_fc_comment($wp_comments[$i]));
    372385        }
  • fastcomments/trunk/fastcomments-wordpress-plugin.php

    r2577451 r2577475  
    44Plugin URI: https://fastcomments.com
    55Description: Live Comments, Fast. A comment system that will delight your users and developers.
    6 Version: 3.9.2
     6Version: 3.9.3
    77Author: winrid @ FastComments
    88License: GPL-2.0+
     
    1414}
    1515
    16 $FASTCOMMENTS_VERSION = 3.92;
     16$FASTCOMMENTS_VERSION = 3.93;
    1717
    1818require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php';
Note: See TracChangeset for help on using the changeset viewer.