Changeset 2678152
- Timestamp:
- 02/14/2022 04:23:42 AM (4 years ago)
- Location:
- fastcomments
- Files:
-
- 40 added
- 8 edited
-
tags/3.11.0 (added)
-
tags/3.11.0/.gitignore (added)
-
tags/3.11.0/LICENSE (added)
-
tags/3.11.0/README.md (added)
-
tags/3.11.0/README.txt (added)
-
tags/3.11.0/admin (added)
-
tags/3.11.0/admin/fastcomments-admin-advanced-settings-view.js (added)
-
tags/3.11.0/admin/fastcomments-admin-advanced-settings-view.php (added)
-
tags/3.11.0/admin/fastcomments-admin-manual-sync-view.js (added)
-
tags/3.11.0/admin/fastcomments-admin-manual-sync-view.php (added)
-
tags/3.11.0/admin/fastcomments-admin-setup-view.js (added)
-
tags/3.11.0/admin/fastcomments-admin-setup-view.php (added)
-
tags/3.11.0/admin/fastcomments-admin-sso-view.css (added)
-
tags/3.11.0/admin/fastcomments-admin-sso-view.js (added)
-
tags/3.11.0/admin/fastcomments-admin-sso-view.php (added)
-
tags/3.11.0/admin/fastcomments-admin-support-view.php (added)
-
tags/3.11.0/admin/fastcomments-admin-view.php (added)
-
tags/3.11.0/admin/fastcomments-admin.css (added)
-
tags/3.11.0/admin/fastcomments-admin.php (added)
-
tags/3.11.0/admin/images (added)
-
tags/3.11.0/admin/images/api.png (added)
-
tags/3.11.0/admin/images/crown.png (added)
-
tags/3.11.0/admin/images/css.png (added)
-
tags/3.11.0/admin/images/debugging.png (added)
-
tags/3.11.0/admin/images/download.png (added)
-
tags/3.11.0/admin/images/home.png (added)
-
tags/3.11.0/admin/images/logo-50.png (added)
-
tags/3.11.0/admin/images/logo.png (added)
-
tags/3.11.0/admin/images/settings.png (added)
-
tags/3.11.0/admin/images/support.png (added)
-
tags/3.11.0/admin/images/sync-status.png (added)
-
tags/3.11.0/admin/images/sync.png (added)
-
tags/3.11.0/core (added)
-
tags/3.11.0/core/FastCommentsIntegrationCore.php (added)
-
tags/3.11.0/core/FastCommentsWordPressIntegration.php (added)
-
tags/3.11.0/fastcomments-wordpress-plugin.php (added)
-
tags/3.11.0/public (added)
-
tags/3.11.0/public/fastcomments-public.php (added)
-
tags/3.11.0/public/fastcomments-widget-view.php (added)
-
tags/3.11.0/uninstall.php (added)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/fastcomments-admin-manual-sync-view.js (modified) (1 diff)
-
trunk/admin/fastcomments-admin-manual-sync-view.php (modified) (2 diffs)
-
trunk/admin/fastcomments-admin-setup-view.php (modified) (3 diffs)
-
trunk/core/FastCommentsIntegrationCore.php (modified) (7 diffs)
-
trunk/core/FastCommentsWordPressIntegration.php (modified) (1 diff)
-
trunk/fastcomments-wordpress-plugin.php (modified) (2 diffs)
-
trunk/public/fastcomments-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastcomments/trunk/README.txt
r2661187 r2678152 3 3 Tags: live comments, comments, comment spam, comment system, fast comments, live commenting 4 4 Requires at least: 4.6 5 Tested up to: 5. 86 Stable tag: 3.1 0.55 Tested up to: 5.9 6 Stable tag: 3.11.0 7 7 Requires PHP: 5.2.5 8 8 License: GPLv2 or later … … 86 86 == Changelog == 87 87 88 = 3.11.0 = 89 * Option to opt out of initial sync during setup. 90 * Ability to perform full sync manually at any time. 91 * Sync improvements (no longer misses first comment in database...). 92 88 93 = 3.10.5 = 89 94 * Improvements to the chunk splitting algorithm for initial setup. No longer gets stuck on sites with very large number of large comments. -
fastcomments/trunk/admin/fastcomments-admin-manual-sync-view.js
r2660486 r2678152 1 1 (function () { 2 2 3 const enableButton = document.getElementById('fc-sync-to-wp'); 4 const enableCancellationButton = document.getElementById('fc-sync-to-wp-cancel-button'); 5 const enableCancellationButtonInProgress = document.getElementById('fc-sync-to-wp-cancel-button-in-progress'); 6 const enableConfirmationButton = document.getElementById('fc-sync-to-wp-confirm-button'); 7 const confirmationArea = document.querySelector('#dialog-sync-to-wp .confirmation'); 8 const inProgressArea = document.querySelector('#dialog-sync-to-wp .in-progress'); 9 const inProgressStatusText = document.getElementById('in-progress-status-text'); 10 11 jQuery('#dialog-sync-to-wp').dialog({ 12 title: 'Sync To WordPress Confirmation', 13 dialogClass: 'wp-dialog', 14 autoOpen: false, 15 draggable: false, 16 width: 'auto', 17 modal: true, 18 resizable: true, 19 closeOnEscape: true, 20 position: { 21 my: "center", 22 at: "center", 23 of: window 24 }, 25 open: function () { 26 // close dialog by clicking the overlay behind it 27 jQuery('.ui-widget-overlay').bind('click', function () { 28 jQuery('#dialog-sync-to-wp').dialog('close'); 29 }); 30 }, 31 create: function () { 32 // style fix for WordPress admin 33 jQuery('.ui-dialog-titlebar-close').addClass('ui-button'); 34 }, 35 }); 36 37 enableButton.addEventListener('click', function () { 38 jQuery('#dialog-sync-to-wp').dialog('open'); 39 }); 40 41 enableCancellationButton.addEventListener('click', function () { 42 jQuery('#dialog-sync-to-wp').dialog('close'); 43 }); 44 45 let cancelled = false; 46 enableCancellationButtonInProgress.addEventListener('click', function () { 47 cancelled = true; 48 jQuery('#dialog-sync-to-wp').dialog('close'); 49 }); 50 51 function centerDialog() { 52 jQuery('#dialog-sync-to-wp').dialog('option', 'position', {my: "center", at: "center", of: window}); 3 function setupFCToWPUI() { 4 const enableButton = document.getElementById('fc-sync-to-wp'); 5 const enableCancellationButton = document.getElementById('fc-sync-to-wp-cancel-button'); 6 const enableCancellationButtonInProgress = document.getElementById('fc-sync-to-wp-cancel-button-in-progress'); 7 const enableConfirmationButton = document.getElementById('fc-sync-to-wp-confirm-button'); 8 const confirmationArea = document.querySelector('#dialog-sync-to-wp .confirmation'); 9 const inProgressArea = document.querySelector('#dialog-sync-to-wp .in-progress'); 10 const inProgressStatusText = document.getElementById('fc-sync-to-wp-in-progress-status-text'); 11 12 jQuery('#dialog-sync-to-wp').dialog({ 13 title: 'Sync To WordPress Confirmation', 14 dialogClass: 'wp-dialog', 15 autoOpen: false, 16 draggable: false, 17 width: 'auto', 18 modal: true, 19 resizable: true, 20 closeOnEscape: true, 21 position: { 22 my: "center", 23 at: "center", 24 of: window 25 }, 26 open: function () { 27 // close dialog by clicking the overlay behind it 28 jQuery('.ui-widget-overlay').bind('click', function () { 29 jQuery('#dialog-sync-to-wp').dialog('close'); 30 }); 31 }, 32 create: function () { 33 // style fix for WordPress admin 34 jQuery('.ui-dialog-titlebar-close').addClass('ui-button'); 35 }, 36 }); 37 38 enableButton.addEventListener('click', function () { 39 jQuery('#dialog-sync-to-wp').dialog('open'); 40 }); 41 42 enableCancellationButton.addEventListener('click', function () { 43 jQuery('#dialog-sync-to-wp').dialog('close'); 44 }); 45 46 let cancelled = false; 47 enableCancellationButtonInProgress.addEventListener('click', function () { 48 cancelled = true; 49 jQuery('#dialog-sync-to-wp').dialog('close'); 50 }); 51 52 function centerDialog() { 53 jQuery('#dialog-sync-to-wp').dialog('option', 'position', {my: "center", at: "center", of: window}); 54 } 55 56 enableConfirmationButton.addEventListener('click', function () { 57 cancelled = false; 58 jQuery('#dialog-sync-to-wp').dialog('option', 'title', 'Downloading Comments to WordPress...'); 59 60 confirmationArea.classList.add('hidden'); 61 inProgressArea.classList.remove('hidden'); 62 inProgressStatusText.innerHTML = 'Beginning the sync, determining how many comments we need to download...'; 63 centerDialog(); 64 65 function onError() { 66 inProgressStatusText.innerHTML = 'Sync failed. Please try again. If this persists, reach out to support.'; 67 enableCancellationButtonInProgress.innerHTML = 'Close'; 68 centerDialog(); 69 } 70 71 let countSoFar = 0; 72 let totalCount = 0; 73 74 function onDone() { 75 if (cancelled) { 76 return; 77 } 78 jQuery('#dialog-sync-to-wp').dialog('option', 'title', 'Downloaded Comments to WordPress!'); 79 inProgressStatusText.innerHTML = '✔ Sync complete! Downloaded ' + Number(countSoFar).toLocaleString() + ' of ' + Number(totalCount).toLocaleString() + ' Comments.'; 80 enableCancellationButtonInProgress.innerHTML = 'Close'; 81 centerDialog(); 82 } 83 84 function next(includeCount) { 85 if (cancelled) { 86 return; 87 } 88 let url = window.FC_DATA.siteUrl + '/index.php?rest_route=/fastcomments/v1/api/sync-to-wp'; 89 if (includeCount) { 90 url += '&includeCount=true'; 91 } 92 if (countSoFar) { 93 url += '&skip=' + countSoFar; 94 } 95 jQuery.ajax({ 96 url: url, 97 method: 'PUT', 98 dataType: 'json', 99 success: function success(response) { 100 if (response && response.status === 'success') { 101 if (response.totalCount !== null) { 102 totalCount = response.totalCount; 103 } 104 if (response.count) { 105 countSoFar += response.count; 106 } 107 inProgressStatusText.innerHTML = 'Downloading... Downloaded ' + Number(countSoFar).toLocaleString() + ' out of ' + Number(totalCount).toLocaleString() + ' comments.'; 108 if (response.hasMore) { 109 setTimeout(function () { 110 next(); 111 }, 100); 112 } else { 113 onDone(); 114 } 115 } else { 116 onError(); 117 } 118 }, 119 error: onError, 120 beforeSend: function (xhr) { 121 xhr.setRequestHeader('X-WP-Nonce', window.FC_DATA.nonce); 122 } 123 }); 124 } 125 126 next(true); 127 }); 53 128 } 54 129 55 enableConfirmationButton.addEventListener('click', function () { 56 cancelled = false; 57 jQuery('#dialog-sync-to-wp').dialog('option', 'title', 'Downloading Comments to WordPress...'); 58 59 confirmationArea.classList.add('hidden'); 60 inProgressArea.classList.remove('hidden'); 61 inProgressStatusText.innerHTML = 'Beginning the sync, determining how many comments we need to download...'; 62 centerDialog(); 63 64 function onError() { 65 inProgressStatusText.innerHTML = 'Sync failed. Please try again. If this persists, reach out to support.'; 66 enableCancellationButtonInProgress.innerHTML = 'Close'; 130 function setupWPToFCUI() { 131 const enableButton = document.getElementById('wp-sync-to-fc'); 132 const enableCancellationButton = document.getElementById('wp-sync-to-fc-cancel-button'); 133 const enableCancellationButtonInProgress = document.getElementById('wp-sync-to-fc-cancel-button-in-progress'); 134 const enableConfirmationButton = document.getElementById('wp-sync-to-fc-confirm-button'); 135 const confirmationArea = document.querySelector('#dialog-sync-to-fc .confirmation'); 136 const inProgressArea = document.querySelector('#dialog-sync-to-fc .in-progress'); 137 const inProgressStatusText = document.getElementById('wp-sync-to-fc-in-progress-status-text'); 138 139 jQuery('#dialog-sync-to-fc').dialog({ 140 title: 'Sync To FastComments.com Confirmation', 141 dialogClass: 'wp-dialog', 142 autoOpen: false, 143 draggable: false, 144 width: 'auto', 145 modal: true, 146 resizable: true, 147 closeOnEscape: true, 148 position: { 149 my: "center", 150 at: "center", 151 of: window 152 }, 153 open: function () { 154 // close dialog by clicking the overlay behind it 155 jQuery('.ui-widget-overlay').bind('click', function () { 156 jQuery('#dialog-sync-to-fc').dialog('close'); 157 }); 158 }, 159 create: function () { 160 // style fix for WordPress admin 161 jQuery('.ui-dialog-titlebar-close').addClass('ui-button'); 162 }, 163 }); 164 165 enableButton.addEventListener('click', function () { 166 jQuery('#dialog-sync-to-fc').dialog('open'); 167 }); 168 169 enableCancellationButton.addEventListener('click', function () { 170 jQuery('#dialog-sync-to-fc').dialog('close'); 171 }); 172 173 let cancelled = false; 174 enableCancellationButtonInProgress.addEventListener('click', function () { 175 cancelled = true; 176 jQuery('#dialog-sync-to-fc').dialog('close'); 177 }); 178 179 function centerDialog() { 180 jQuery('#dialog-sync-to-fc').dialog('option', 'position', {my: "center", at: "center", of: window}); 181 } 182 183 enableConfirmationButton.addEventListener('click', function () { 184 cancelled = false; 185 jQuery('#dialog-sync-to-fc').dialog('option', 'title', 'Uploading Comments to FastComments.com...'); 186 187 confirmationArea.classList.add('hidden'); 188 inProgressArea.classList.remove('hidden'); 189 inProgressStatusText.innerHTML = 'Beginning the sync, determining how many comments we need to upload...'; 67 190 centerDialog(); 68 } 69 70 let countSoFar = 0; 71 let totalCount = 0; 72 73 function onDone() { 74 if (cancelled) { 75 return; 76 } 77 jQuery('#dialog-sync-to-wp').dialog('option', 'title', 'Downloaded Comments to WordPress!'); 78 inProgressStatusText.innerHTML = '✔ Sync complete! Downloaded ' + Number(countSoFar).toLocaleString() + ' of ' + Number(totalCount).toLocaleString() + ' Comments.'; 79 enableCancellationButtonInProgress.innerHTML = 'Close'; 80 centerDialog(); 81 } 82 83 function next(includeCount) { 84 if (cancelled) { 85 return; 86 } 87 let url = window.FC_DATA.siteUrl + '/index.php?rest_route=/fastcomments/v1/api/sync-to-wp'; 88 if (includeCount) { 89 url += '&includeCount=true'; 90 } 91 if (countSoFar) { 92 url += '&skip=' + countSoFar; 93 } 94 jQuery.ajax({ 95 url: url, 96 method: 'PUT', 97 dataType: 'json', 98 success: function success(response) { 99 if (response && response.status === 'success') { 100 if (response.totalCount !== null) { 101 totalCount = response.totalCount; 191 192 function onError() { 193 inProgressStatusText.innerHTML = 'Sync failed. Please try again. If this persists, reach out to support.'; 194 enableCancellationButtonInProgress.innerHTML = 'Close'; 195 centerDialog(); 196 } 197 198 let countSoFar = 0; 199 let totalCount = 0; 200 201 function onDone() { 202 if (cancelled) { 203 return; 204 } 205 jQuery('#dialog-sync-to-fc').dialog('option', 'title', 'Uploaded Comments to FastComments.com!'); 206 // countSoFar can be > totalCount in the event of retries or chunking 207 inProgressStatusText.innerHTML = '✔ Sync complete! Uploaded ' + Number(Math.min(countSoFar, totalCount)).toLocaleString() + ' of ' + Number(totalCount).toLocaleString() + ' Comments.'; 208 enableCancellationButtonInProgress.innerHTML = 'Close'; 209 centerDialog(); 210 } 211 212 function next(isFirst) { 213 if (cancelled) { 214 return; 215 } 216 let url = window.FC_DATA.siteUrl + '/index.php?rest_route=/fastcomments/v1/api/sync-to-fc'; 217 if (isFirst) { 218 url += '&includeCount=true'; 219 url += '&reset=true'; 220 } 221 jQuery.ajax({ 222 url: url, 223 method: 'PUT', 224 dataType: 'json', 225 success: function success(response) { 226 if (response && response.status === 'success') { 227 if (response.totalCount !== null) { 228 totalCount = response.totalCount; 229 } 230 if (typeof response.commandResult === 'number') { 231 countSoFar += response.commandResult; 232 } 233 inProgressStatusText.innerHTML = 'Uploading... Uploaded ' + Number(countSoFar).toLocaleString() + ' out of ' + Number(totalCount).toLocaleString() + ' comments.'; 234 if (response.hasMore) { 235 setTimeout(function () { 236 next(); 237 }, 100); 238 } else { 239 onDone(); 240 } 241 } else { 242 onError(); 102 243 } 103 if (response.count) { 104 countSoFar += response.count; 105 } 106 inProgressStatusText.innerHTML = 'Downloading... Downloaded ' + Number(countSoFar).toLocaleString() + ' out of ' + Number(totalCount).toLocaleString() + ' comments.'; 107 if (response.hasMore) { 108 setTimeout(function() { 109 next(); 110 }, 100); 111 } else { 112 onDone(); 113 } 114 } else { 115 onError(); 244 }, 245 error: onError, 246 beforeSend: function (xhr) { 247 xhr.setRequestHeader('X-WP-Nonce', window.FC_DATA.nonce); 116 248 } 117 } ,118 error: onError,119 beforeSend: function (xhr) { 120 xhr.setRequestHeader('X-WP-Nonce', window.FC_DATA.nonce);121 }122 });123 } 124 next(true);125 });249 }); 250 } 251 252 next(true); 253 }); 254 } 255 256 setupFCToWPUI(); 257 setupWPToFCUI(); 126 258 })(); -
fastcomments/trunk/admin/fastcomments-admin-manual-sync-view.php
r2660486 r2678152 16 16 </noscript> 17 17 18 <p>If you didn't upload your comments during the initial setup, or would like to do it anyway, you can do it now here.</p> 19 <button class="button-primary" id="wp-sync-to-fc">Run Upload WordPress Comments → <b>to</b> → FastComments.com.</button> 20 18 21 <p>FastComments automatically keeps your comments synced to your WordPress installation. However, the option exists to re-download all comments from FastComments to WordPress.</p> 19 <button class="button-primary" id="fc-sync-to-wp">Run Sync FastComments.com → <b>to</b> → WordPress.</button> 22 <button class="button-primary" id="fc-sync-to-wp">Run Download FastComments.com → <b>to</b> → WordPress.</button> 23 24 <div id="dialog-sync-to-fc" class="hidden"> 25 <div class="confirmation"> 26 <h3>Are you sure?</h3> 27 <p> 28 Running the sync from WordPress to FastComments will incrementally **upload** all your comments to your FastComments.com account. 29 </p> 30 <p> 31 It will not remove any comments from your WordPress installation. 32 </p> 33 <p> 34 This is not needed to keep your WordPress install up to date. This is only to upload your comments <b>from</b> WordPress <b>to</b> FastComments.com. 35 </p> 36 <p>After clicking "Yes, Perform The Sync", you must keep this page open for it to complete.</p> 37 <p class="submit"> 38 <button type="button" class="button button-primary" id="wp-sync-to-fc-confirm-button">Yes, perform the upload.</button> 39 <button type="button" class="button" id="wp-sync-to-fc-cancel-button">Cancel</button> 40 </p> 41 </div> 42 <div class="in-progress hidden"> 43 <p id="wp-sync-to-fc-in-progress-status-text"></p> 44 <p class="submit"> 45 <button type="button" class="button" id="wp-sync-to-fc-cancel-button-in-progress">Cancel</button> 46 </p> 47 </div> 48 </div> 20 49 21 50 <div id="dialog-sync-to-wp" class="hidden"> … … 40 69 </div> 41 70 <div class="in-progress hidden"> 42 <p id=" in-progress-status-text"></p>71 <p id="fc-sync-to-wp-in-progress-status-text"></p> 43 72 <p class="submit"> 44 73 <button type="button" class="button" id="fc-sync-to-wp-cancel-button-in-progress">Cancel</button> -
fastcomments/trunk/admin/fastcomments-admin-setup-view.php
r2660486 r2678152 11 11 <h2>Do you have a FastComments Account?</h2> 12 12 <a class="button-primary button-has-account" 13 href="https://fastcomments.com/auth/my-account/integrations/v1/ setup?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true"13 href="https://fastcomments.com/auth/my-account/integrations/v1/confirm?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true" 14 14 target="_blank">Yes</a> 15 15 <a class="button-primary button-no-account" 16 href="https://fastcomments.com/auth/my-account/integrations/v1/ setup?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=false"16 href="https://fastcomments.com/auth/my-account/integrations/v1/confirm?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=false" 17 17 target="_blank">No</a> 18 18 <?php } else if (!get_option('fastcomments_setup')) { ?> … … 23 23 24 24 <a class="button-primary" 25 href="https://fastcomments.com/auth/my-account/integrations/v1/ setup?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true"25 href="https://fastcomments.com/auth/my-account/integrations/v1/confirm?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true" 26 26 target="_blank">Re-Run Setup</a> 27 27 <?php } else { ?> … … 33 33 34 34 <a class="button-primary" 35 href="https://fastcomments.com/auth/my-account/integrations/v1/ setup?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true"35 href="https://fastcomments.com/auth/my-account/integrations/v1/confirm?token=<?php echo get_option("fastcomments_token") ?>&hasAccount=true" 36 36 target="_blank">Re-Run Setup</a> 37 37 <?php } ?> -
fastcomments/trunk/core/FastCommentsIntegrationCore.php
r2661187 r2678152 183 183 $this->commandSendComments($token); 184 184 break; 185 case 'SetSyncDone': 186 $this->commandSetSyncDone(); 187 break; 185 188 } 186 189 } … … 242 245 public function commandSendComments($token) { 243 246 /** 244 * Fetch 500 comments a time from the DB. 245 * Split them up into chunks of 100. 247 * Fetch 100 comments a time from the DB. 246 248 * If the server complains the payload is too large, recursively split the chunk by / 10. 247 249 */ … … 249 251 if (!$this->canAckLock("commandSendComments", 60)) { 250 252 $this->log('debug', 'Can not send right now, waiting for previous attempt to finish.'); 251 return ;253 return 'LOCK_WAITING'; 252 254 } 253 255 $lastSendDate = $this->getSettingValue('fastcomments_stream_last_send_timestamp'); 254 256 $lastSentId = $this->getSettingValue('fastcomments_stream_last_send_id'); 255 $commentCount = $this->getCommentCount($lastSentId ? $lastSentId : 0);257 $commentCount = $this->getCommentCount($lastSentId ? $lastSentId : -1); 256 258 if ($commentCount == 0) { 257 259 $this->log('debug', "No comments to send. Telling server. lastSendDate=[$lastSendDate] lastSentId=[$lastSentId]"); 260 // TODO abstract out and use for initial setup to skip upload 258 261 $requestBody = json_encode( 259 262 array( … … 265 268 $this->log('debug', "Got POST /comments response status code=[$httpResponse->responseStatusCode]"); 266 269 $this->setSetupDone(); 267 return ;270 return 0; 268 271 } 269 272 $this->log('debug', 'Send comments command loop...'); 270 $getCommentsResponse = $this->getComments($lastSentId ? $lastSentId : 0); 273 $getCommentsResponse = $this->getComments($lastSentId ? $lastSentId : -1); 274 $countSynced = 0; 271 275 if ($getCommentsResponse['status'] === 'success') { 272 276 $count = count($getCommentsResponse['comments']); … … 296 300 $dynamicChunkSizeActual = count($dynamicChunk); 297 301 $httpResponse = $this->makeHTTPRequest('POST', "$this->baseUrl/comments?token=$token", $requestBody); 298 $this->log('debug', "Got POST /comments response status code=[$httpResponse->responseStatusCode] and chunk size $dynamicChunkSize ");302 $this->log('debug', "Got POST /comments response status code=[$httpResponse->responseStatusCode] and chunk size $dynamicChunkSize (actual=$dynamicChunkSizeActual)"); 299 303 if ($httpResponse->responseStatusCode === 200) { 300 304 $response = json_decode($httpResponse->responseBody); 301 305 if ($response->status === 'success') { 302 306 foreach ($response->commentIds as $wpId => $fcId) { 303 update_comment_meta((int) $wpId, 'fastcomments_id', $fcId);307 update_comment_meta((int)$wpId, 'fastcomments_id', $fcId); 304 308 } 305 309 $countRemaining = $countRemainingIfSuccessful; … … 328 332 $this->setSetupDone(); 329 333 } 334 $countSynced = $count; 330 335 } else { 331 336 $status = $getCommentsResponse['status']; … … 335 340 $this->clearLock("commandSendComments"); 336 341 $this->log('debug', 'Done sending comments'); 342 return $countSynced; 343 } 344 345 public function commandSetSyncDone() { 346 $this->setSetupDone(); 337 347 } 338 348 339 349 private function setSetupDone() { 350 /** 351 * Note - important we don't set the last stream fetch timestamp here to now(), because our timestamps 352 * will be different than the server's, and that has no impact on setting the setup as done anyway. 353 * The fastcomments_stream_last_fetch_timestamp should be set whenever we actually fetch the stream. 354 */ 340 355 $this->setSettingValue('fastcomments_setup', true); 341 $this->setSettingValue('fastcomments_stream_last_fetch_timestamp', time() * 1000);342 356 $this->clearLock("commandSendComments"); 343 357 } -
fastcomments/trunk/core/FastCommentsWordPressIntegration.php
r2660486 r2678152 499 499 $where = $this->getCommentQueryWhere($afterId); 500 500 global $wpdb; 501 // Ordering by comment_ID makes the sort stable through pagination. 501 502 $sql = "SELECT * FROM $wpdb->comments WHERE $where ORDER BY comment_ID ASC LIMIT 100"; 502 503 $query_result = $wpdb->get_results($sql); -
fastcomments/trunk/fastcomments-wordpress-plugin.php
r2661187 r2678152 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.1 0.56 Version: 3.11.0 7 7 Author: winrid @ FastComments 8 8 License: GPL-2.0+ … … 14 14 } 15 15 16 $FASTCOMMENTS_VERSION = 3.1 05;16 $FASTCOMMENTS_VERSION = 3.110; 17 17 18 18 require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php'; -
fastcomments/trunk/public/fastcomments-public.php
r2660486 r2678152 29 29 'methods' => 'PUT', 30 30 'callback' => array($this, 'handle_sync_to_wp_request'), 31 'permission_callback' => function () { 32 return current_user_can('activate_plugins'); 33 } 34 )); 35 register_rest_route('fastcomments/v1', '/api/sync-to-fc', array( 36 'methods' => 'PUT', 37 'callback' => array($this, 'handle_sync_to_fc_request'), 31 38 'permission_callback' => function () { 32 39 return current_user_can('activate_plugins'); … … 103 110 } 104 111 112 public function handle_sync_to_fc_request(WP_REST_Request $request) { 113 $includeCount = $request->get_param('includeCount'); 114 $reset = $request->get_param('reset'); 115 116 require_once plugin_dir_path(__FILE__) . '../core/FastCommentsWordPressIntegration.php'; 117 $fastcomments = new FastCommentsWordPressIntegration(); 118 119 if ($reset) { 120 $fastcomments->setSettingValue('fastcomments_stream_last_send_timestamp', null); 121 $fastcomments->setSettingValue('fastcomments_stream_last_send_id', null); 122 } 123 124 $token = $fastcomments->getSettingValue('fastcomments_token'); 125 $countSyncedOrErrorMessage = $fastcomments->commandSendComments($token); 126 127 return new WP_REST_Response(array('status' => 'success', 'hasMore' => $countSyncedOrErrorMessage === 'LOCK_WAITING' || $countSyncedOrErrorMessage > 0, 'totalCount' => $includeCount ? $fastcomments->getCommentCount(-1) : null, 'commandResult' => $countSyncedOrErrorMessage), 200); 128 } 129 105 130 public static function get_config_for_post($post) { 106 131 $ssoKey = get_option('fastcomments_sso_key');
Note: See TracChangeset
for help on using the changeset viewer.