Changeset 2577475
- Timestamp:
- 08/03/2021 10:34:26 PM (5 years ago)
- Location:
- fastcomments
- Files:
-
- 34 added
- 4 edited
-
tags/3.9.3 (added)
-
tags/3.9.3/.gitignore (added)
-
tags/3.9.3/LICENSE (added)
-
tags/3.9.3/README.md (added)
-
tags/3.9.3/README.txt (added)
-
tags/3.9.3/admin (added)
-
tags/3.9.3/admin/fastcomments-admin-setup-view.js (added)
-
tags/3.9.3/admin/fastcomments-admin-setup-view.php (added)
-
tags/3.9.3/admin/fastcomments-admin-sso-view.css (added)
-
tags/3.9.3/admin/fastcomments-admin-sso-view.js (added)
-
tags/3.9.3/admin/fastcomments-admin-sso-view.php (added)
-
tags/3.9.3/admin/fastcomments-admin-support-view.php (added)
-
tags/3.9.3/admin/fastcomments-admin-view.php (added)
-
tags/3.9.3/admin/fastcomments-admin.css (added)
-
tags/3.9.3/admin/fastcomments-admin.php (added)
-
tags/3.9.3/admin/images (added)
-
tags/3.9.3/admin/images/api.png (added)
-
tags/3.9.3/admin/images/crown.png (added)
-
tags/3.9.3/admin/images/css.png (added)
-
tags/3.9.3/admin/images/debugging.png (added)
-
tags/3.9.3/admin/images/download.png (added)
-
tags/3.9.3/admin/images/home.png (added)
-
tags/3.9.3/admin/images/logo-50.png (added)
-
tags/3.9.3/admin/images/logo.png (added)
-
tags/3.9.3/admin/images/support.png (added)
-
tags/3.9.3/admin/images/sync.png (added)
-
tags/3.9.3/core (added)
-
tags/3.9.3/core/FastCommentsIntegrationCore.php (added)
-
tags/3.9.3/core/FastCommentsWordPressIntegration.php (added)
-
tags/3.9.3/fastcomments-wordpress-plugin.php (added)
-
tags/3.9.3/public (added)
-
tags/3.9.3/public/fastcomments-public.php (added)
-
tags/3.9.3/public/fastcomments-widget-view.php (added)
-
tags/3.9.3/uninstall.php (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/core/FastCommentsIntegrationCore.php (modified) (5 diffs)
-
trunk/core/FastCommentsWordPressIntegration.php (modified) (3 diffs)
-
trunk/fastcomments-wordpress-plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastcomments/trunk/README.txt
r2577451 r2577475 4 4 Requires at least: 4.6 5 5 Tested up to: 5.8 6 Stable tag: 3.9. 26 Stable tag: 3.9.3 7 7 Requires PHP: 5.2.4 8 8 License: GPLv2 or later … … 85 85 == Changelog == 86 86 87 = 3.9.3 = 88 * Stability improvements and sync-related bugfixes. 89 87 90 = 3.9.2 = 88 91 * Stability improvements and sync-related bugfixes. Initial setup made more intuitive in some areas. -
fastcomments/trunk/core/FastCommentsIntegrationCore.php
r2577451 r2577475 38 38 public abstract function handleEvents($events); 39 39 40 public abstract function getCommentCount( );40 public abstract function getCommentCount($startFromDateTime); 41 41 42 42 public abstract function getComments($startFromDateTime); … … 246 246 $startedAt = time(); 247 247 $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) { 251 249 $this->log('debug', 'No comments to send. Telling server.'); 252 250 $requestBody = json_encode( … … 261 259 return; 262 260 } 263 while ($hasMore && time() - $startedAt < 30 * 1000) {261 // while ($hasMore && time() - $startedAt < 30 * 1000) { 264 262 $this->log('debug', 'Send comments command loop...'); 265 263 $getCommentsResponse = $this->getComments($lastSendDate ? $lastSendDate : 0); … … 268 266 $hasMore = $getCommentsResponse['hasMore']; 269 267 $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 // } 291 292 } 292 293 } else { 293 294 $this->setSetupDone(); 294 break;295 // break; 295 296 } 296 297 } else { … … 299 300 $debugHasMore = $getCommentsResponse['hasMore']; 300 301 $this->log('error', "Failed to get comments to send: status=[$status] comments=[$comments] hasMore=[$debugHasMore]}"); 301 break;302 } 303 }302 // break; 303 } 304 // } 304 305 $this->log('debug', 'Done sending comments'); 305 306 } -
fastcomments/trunk/core/FastCommentsWordPressIntegration.php
r2577451 r2577475 42 42 global $FASTCOMMENTS_VERSION; 43 43 44 if ((string) $FASTCOMMENTS_VERSION !== (string)$this->getSettingValue('fastcomments_version')) {44 if ((string)$FASTCOMMENTS_VERSION !== (string)$this->getSettingValue('fastcomments_version')) { 45 45 $is_old_version = !get_option('fc_fastcomments_comment_ids_version'); 46 46 if ($is_old_version) { … … 224 224 225 225 $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; 227 227 $finalpostId = $wp_comment['comment_post_ID']; 228 228 $wp_comment['comment_post_url'] = $fc_comment->url; … … 349 349 } 350 350 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 // } 354 365 } 355 366 356 367 public function getComments($startFromDateTime) { 357 $limit = 100;368 // $limit = 100; 358 369 $args = array( 359 'number' => $limit + 1,370 // 'number' => $limit + 1, 360 371 'date_query' => array( 361 372 'after' => date('c', $startFromDateTime ? $startFromDateTime / 1000 : 0), 362 373 'inclusive' => true 363 374 ), 364 'orderby' => 'comment_date',375 'orderby' => array('comment_date', 'comment_ID'), 365 376 'order' => 'ASC' 366 377 ); 367 378 $wp_comments = get_comments($args); 368 $has_more = count($wp_comments) > $limit; 379 // $has_more = count($wp_comments) > $limit; 380 $has_more = false; 369 381 $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++) { 371 384 array_push($fc_comments, $this->wp_to_fc_comment($wp_comments[$i])); 372 385 } -
fastcomments/trunk/fastcomments-wordpress-plugin.php
r2577451 r2577475 4 4 Plugin URI: https://fastcomments.com 5 5 Description: Live Comments, Fast. A comment system that will delight your users and developers. 6 Version: 3.9. 26 Version: 3.9.3 7 7 Author: winrid @ FastComments 8 8 License: GPL-2.0+ … … 14 14 } 15 15 16 $FASTCOMMENTS_VERSION = 3.9 2;16 $FASTCOMMENTS_VERSION = 3.93; 17 17 18 18 require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php';
Note: See TracChangeset
for help on using the changeset viewer.