Changeset 2586216
- Timestamp:
- 08/20/2021 11:27:02 PM (5 years ago)
- Location:
- fastcomments
- Files:
-
- 34 added
- 3 edited
-
tags/3.9.8 (added)
-
tags/3.9.8/.gitignore (added)
-
tags/3.9.8/LICENSE (added)
-
tags/3.9.8/README.md (added)
-
tags/3.9.8/README.txt (added)
-
tags/3.9.8/admin (added)
-
tags/3.9.8/admin/fastcomments-admin-setup-view.js (added)
-
tags/3.9.8/admin/fastcomments-admin-setup-view.php (added)
-
tags/3.9.8/admin/fastcomments-admin-sso-view.css (added)
-
tags/3.9.8/admin/fastcomments-admin-sso-view.js (added)
-
tags/3.9.8/admin/fastcomments-admin-sso-view.php (added)
-
tags/3.9.8/admin/fastcomments-admin-support-view.php (added)
-
tags/3.9.8/admin/fastcomments-admin-view.php (added)
-
tags/3.9.8/admin/fastcomments-admin.css (added)
-
tags/3.9.8/admin/fastcomments-admin.php (added)
-
tags/3.9.8/admin/images (added)
-
tags/3.9.8/admin/images/api.png (added)
-
tags/3.9.8/admin/images/crown.png (added)
-
tags/3.9.8/admin/images/css.png (added)
-
tags/3.9.8/admin/images/debugging.png (added)
-
tags/3.9.8/admin/images/download.png (added)
-
tags/3.9.8/admin/images/home.png (added)
-
tags/3.9.8/admin/images/logo-50.png (added)
-
tags/3.9.8/admin/images/logo.png (added)
-
tags/3.9.8/admin/images/support.png (added)
-
tags/3.9.8/admin/images/sync.png (added)
-
tags/3.9.8/core (added)
-
tags/3.9.8/core/FastCommentsIntegrationCore.php (added)
-
tags/3.9.8/core/FastCommentsWordPressIntegration.php (added)
-
tags/3.9.8/fastcomments-wordpress-plugin.php (added)
-
tags/3.9.8/public (added)
-
tags/3.9.8/public/fastcomments-public.php (added)
-
tags/3.9.8/public/fastcomments-widget-view.php (added)
-
tags/3.9.8/uninstall.php (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/core/FastCommentsWordPressIntegration.php (modified) (7 diffs)
-
trunk/fastcomments-wordpress-plugin.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastcomments/trunk/README.txt
r2586120 r2586216 4 4 Requires at least: 4.6 5 5 Tested up to: 5.8 6 Stable tag: 3.9. 76 Stable tag: 3.9.8 7 7 Requires PHP: 5.2.4 8 8 License: GPLv2 or later … … 84 84 85 85 == Changelog == 86 87 = 3.9.8 = 88 * Improved support for re-running the sync multiple times without creating duplicate data. 86 89 87 90 = 3.9.7 = -
fastcomments/trunk/core/FastCommentsWordPressIntegration.php
r2585075 r2586216 190 190 191 191 public function fc_to_wp_comment($fc_comment) { 192 $wp_comment = array();193 192 /* 194 193 We intentionally don't send these fields, as they don't apply to us so they won't ever change on our side. … … 200 199 */ 201 200 202 // wordpress timestamp format is Y-m-d H:i:s (mysql date column type)203 $timestamp = strtotime($fc_comment->date);204 $date_formatted_gmt = date('Y-m-d H:i:s', $timestamp);205 $date_formatted = get_date_from_gmt($date_formatted_gmt);206 207 $this->log('debug', "Dates: got $date_formatted_gmt -> $date_formatted from $fc_comment->date -> $timestamp");208 209 $wp_id = $this->getWPCommentId($fc_comment->_id);210 $wp_parent_id = isset($fc_comment->parentId) && $fc_comment->parentId ? $this->getWPCommentId($fc_comment->parentId) : 0;211 212 201 $post_id = null; 213 202 $user_id = null; … … 220 209 $user_id = $fc_comment->meta->wpUserId; 221 210 } 222 } else { 223 $post_id = (int) $fc_comment->urlId; 224 } 211 } 212 213 if (!$post_id) { 214 return null; // don't try to set post id to a url... this is probably not a comment from the WP integration. 215 } 216 217 $wp_comment = array(); 218 219 // wordpress timestamp format is Y-m-d H:i:s (mysql date column type) 220 $timestamp = strtotime($fc_comment->date); 221 $date_formatted_gmt = date('Y-m-d H:i:s', $timestamp); 222 $date_formatted = get_date_from_gmt($date_formatted_gmt); 223 224 $this->log('debug', "Dates: got $date_formatted_gmt -> $date_formatted from $fc_comment->date -> $timestamp"); 225 226 $wp_id = $this->getWPCommentId($fc_comment->_id); 227 $wp_parent_id = isset($fc_comment->parentId) && $fc_comment->parentId ? $this->getWPCommentId($fc_comment->parentId) : 0; 225 228 226 229 $wp_comment['comment_ID'] = is_numeric($wp_id) ? $wp_id : null; … … 248 251 $votes = $wp_comment->comment_karma; 249 252 253 // Send the ID our backend knows about, to prevent duplicates in some scenarios. 254 $meta_fc_id = get_comment_meta($wp_comment->comment_ID, 'fastcomments_id', true); 255 if ($meta_fc_id) { 256 $fc_comment['_id'] = $meta_fc_id; 257 } 250 258 $fc_comment['tenantId'] = $this->getSettingValue('fastcomments_tenant_id'); 251 259 $fc_comment['urlId'] = $wp_comment->comment_post_ID; 252 $fc_comment['url'] = get_permalink($wp_comment->comment_post_ID); 260 $permaLink = get_permalink($wp_comment->comment_post_ID); 261 if ($permaLink) { 262 $fc_comment['url'] = $permaLink; 263 } 253 264 $fc_comment['pageTitle'] = get_the_title($wp_comment->comment_post_ID); 254 265 $fc_comment['userId'] = null; … … 292 303 if (!$existingComment) { 293 304 $this->log('debug', "Incoming comment $fcId"); 294 $comment_id_or_false = wp_insert_comment($this->fc_to_wp_comment($eventData->comment)); 295 if ($comment_id_or_false) { 296 $this->addCommentIDMapEntry($fcId, $comment_id_or_false); 305 $new_wp_comment = $this->fc_to_wp_comment($eventData->comment); 306 if ($new_wp_comment) { 307 $comment_id_or_false = wp_insert_comment($new_wp_comment); 308 if ($comment_id_or_false) { 309 $this->addCommentIDMapEntry($fcId, $comment_id_or_false); 310 add_comment_meta($comment_id_or_false, 'fastcomments_id', $eventData->comment->_id, true); 311 } else { 312 $debug_data = $event->data; 313 $this->log('error', "Failed to save comment: $debug_data"); 314 } 297 315 } else { 298 $debug_data = $event->data; 299 $this->log('error', "Failed to save comment: $debug_data"); 316 $this->log('debug', "Skipping sync of $fcId - is not from the WP integration."); 300 317 } 301 318 } else { … … 307 324 $this->log('debug', "Updating comment $fcId"); 308 325 $wp_comment = $this->fc_to_wp_comment($eventData->comment); 309 wp_update_comment($wp_comment); 326 if ($wp_comment) { 327 wp_update_comment($wp_comment); 328 add_comment_meta($wp_comment->comment_ID, 'fastcomments_id', $eventData->comment->_id, true); 329 } else { 330 $this->log('debug', "Skipping sync of $fcId - is not from the WP integration."); 331 } 310 332 break; 311 333 case 'deleted-comment': … … 362 384 // return $wp_comments_count; 363 385 // } else { 364 $count_result = wp_count_comments();365 return $count_result ? $count_result->total_comments : 0;386 $count_result = wp_count_comments(); 387 return $count_result ? $count_result->total_comments : 0; 366 388 // } 367 389 } -
fastcomments/trunk/fastcomments-wordpress-plugin.php
r2586120 r2586216 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. 76 Version: 3.9.8 7 7 Author: winrid @ FastComments 8 8 License: GPL-2.0+ … … 14 14 } 15 15 16 $FASTCOMMENTS_VERSION = 3.9 7;16 $FASTCOMMENTS_VERSION = 3.98; 17 17 18 18 require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php';
Note: See TracChangeset
for help on using the changeset viewer.