Changeset 2771905
- Timestamp:
- 08/18/2022 04:33:40 AM (4 years ago)
- Location:
- fastcomments
- Files:
-
- 40 added
- 5 edited
-
tags/3.12.5 (added)
-
tags/3.12.5/.gitignore (added)
-
tags/3.12.5/LICENSE (added)
-
tags/3.12.5/README.md (added)
-
tags/3.12.5/README.txt (added)
-
tags/3.12.5/admin (added)
-
tags/3.12.5/admin/fastcomments-admin-advanced-settings-view.js (added)
-
tags/3.12.5/admin/fastcomments-admin-advanced-settings-view.php (added)
-
tags/3.12.5/admin/fastcomments-admin-manual-sync-view.js (added)
-
tags/3.12.5/admin/fastcomments-admin-manual-sync-view.php (added)
-
tags/3.12.5/admin/fastcomments-admin-setup-view.js (added)
-
tags/3.12.5/admin/fastcomments-admin-setup-view.php (added)
-
tags/3.12.5/admin/fastcomments-admin-sso-view.css (added)
-
tags/3.12.5/admin/fastcomments-admin-sso-view.js (added)
-
tags/3.12.5/admin/fastcomments-admin-sso-view.php (added)
-
tags/3.12.5/admin/fastcomments-admin-support-view.php (added)
-
tags/3.12.5/admin/fastcomments-admin-view.php (added)
-
tags/3.12.5/admin/fastcomments-admin.css (added)
-
tags/3.12.5/admin/fastcomments-admin.php (added)
-
tags/3.12.5/admin/images (added)
-
tags/3.12.5/admin/images/api.png (added)
-
tags/3.12.5/admin/images/crown.png (added)
-
tags/3.12.5/admin/images/css.png (added)
-
tags/3.12.5/admin/images/debugging.png (added)
-
tags/3.12.5/admin/images/download.png (added)
-
tags/3.12.5/admin/images/home.png (added)
-
tags/3.12.5/admin/images/logo-50.png (added)
-
tags/3.12.5/admin/images/logo.png (added)
-
tags/3.12.5/admin/images/settings.png (added)
-
tags/3.12.5/admin/images/support.png (added)
-
tags/3.12.5/admin/images/sync-status.png (added)
-
tags/3.12.5/admin/images/sync.png (added)
-
tags/3.12.5/core (added)
-
tags/3.12.5/core/FastCommentsIntegrationCore.php (added)
-
tags/3.12.5/core/FastCommentsWordPressIntegration.php (added)
-
tags/3.12.5/fastcomments-wordpress-plugin.php (added)
-
tags/3.12.5/public (added)
-
tags/3.12.5/public/fastcomments-public.php (added)
-
tags/3.12.5/public/fastcomments-widget-view.php (added)
-
tags/3.12.5/uninstall.php (added)
-
trunk/README.txt (modified) (4 diffs)
-
trunk/core/FastCommentsIntegrationCore.php (modified) (11 diffs)
-
trunk/core/FastCommentsWordPressIntegration.php (modified) (1 diff)
-
trunk/fastcomments-wordpress-plugin.php (modified) (2 diffs)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fastcomments/trunk/README.txt
r2768101 r2771905 4 4 Requires at least: 4.6 5 5 Tested up to: 6.0 6 Stable tag: 3.12. 46 Stable tag: 3.12.5 7 7 Requires PHP: 5.2.5 8 8 License: GPLv2 or later … … 48 48 4. Activate the Plugin 49 49 5. Click FastComments in the left admin panel. 50 6. Follow the steps to set up and connect your WordPress installation to our servers. Don't worry, it's just a couple clicks.50 6. Follow the steps to set up and connect your WordPress installation to our servers. Don't worry, it's just a couple clicks. 51 51 52 52 You can expect the sync to take several minutes if you have tens of thousands of comments or more. … … 73 73 = Can I switch back to default WordPress comments? = 74 74 75 By default FastComments keeps your WordPress installation in sync with our servers. We send very small updates, at most once a minute if needed, for any new comments.75 By default, FastComments keeps your WordPress installation in sync with our servers. We send very small updates, at most once a minute if needed, for any new comments. 76 76 77 77 Simply cancel your account and deactivate the plugin to switch back, but we don't think you'll want to! … … 87 87 88 88 == Changelog == 89 90 = 3.12.5 = 91 * Performance improvements for the initial sync. 89 92 90 93 = 3.12.4 = -
fastcomments/trunk/core/FastCommentsIntegrationCore.php
r2752858 r2771905 166 166 $token = $this->getSettingValue('fastcomments_token'); 167 167 if ($token) { 168 $lastFetchDate = $this->getSettingValue('fastcomments_stream_last_fetch_timestamp' );168 $lastFetchDate = $this->getSettingValue('fastcomments_stream_last_fetch_timestamp', true); 169 169 $lastFetchDateToSend = $lastFetchDate ? $lastFetchDate : 0; 170 170 $this->log('debug', "Polling next commands for fromDateTime=[$lastFetchDateToSend]."); … … 198 198 public function commandFetchEvents($token) { 199 199 $this->log('debug', "BEGIN commandFetchEvents"); 200 $fromDateTime = $this->getSettingValue('fastcomments_stream_last_fetch_timestamp' );200 $fromDateTime = $this->getSettingValue('fastcomments_stream_last_fetch_timestamp', true); 201 201 $hasMore = true; 202 202 $startedAt = time(); … … 214 214 } 215 215 $hasMore = !!$response->hasMore; 216 $this->setSettingValue('fastcomments_stream_last_fetch_timestamp', $fromDateTime );216 $this->setSettingValue('fastcomments_stream_last_fetch_timestamp', $fromDateTime, false); 217 217 } else { 218 218 $this->log('error', "Failed to get events: {$rawIntegrationEventsResponse}"); … … 225 225 private function canAckLock($name, $windowSeconds) { 226 226 $settingName = $this->getLockName($name); 227 $lastTime = $this->getSettingValue($settingName); 227 $this->log('debug', "BEGIN canAckLock $settingName with window $windowSeconds"); 228 $lastTime = $this->getSettingValue($settingName, true); 229 if (!$lastTime) { 230 $this->log('debug', "END canAckLock $settingName last lock time $lastTime. Got lock=[1]"); 231 return true; 232 } 228 233 $now = time(); 229 if ($lastTime && $now - $lastTime < $windowSeconds) { 230 return false; 231 } 232 $this->setSettingValue($settingName, $now); 233 return true; 234 $delta = $now - ((int) ($lastTime)); 235 $gotLock = $delta >= $windowSeconds; 236 $this->log('debug', "END canAckLock $settingName last lock time $lastTime. Delta=[$delta] Got lock=[$gotLock]"); 237 return $gotLock; 234 238 } 235 239 236 240 private function tryAckLock($name, $windowSeconds) { 241 $settingName = $this->getLockName($name); 242 $this->log('debug', "BEGIN tryAckLock $settingName with window $windowSeconds"); 237 243 $secondsRemaining = 5; 238 244 $retryInterval = 1; … … 240 246 while (!$gotLock && $secondsRemaining > 0) { 241 247 $gotLock = $this->canAckLock($name, $windowSeconds); 248 $this->log('debug', "PROGRESS tryAckLock $settingName with window $windowSeconds in loop. Got lock=[$gotLock]"); 242 249 if (!$gotLock) { 243 250 $secondsRemaining = $secondsRemaining - $retryInterval; … … 245 252 } 246 253 } 254 if ($gotLock) { 255 $now = time(); 256 $this->log('debug', "PROGRESS tryAckLock acquiring lock $settingName for now=[$now]"); 257 $this->setSettingValue($settingName, $now, false); 258 } 259 $this->log('debug', "END tryAckLock $settingName Got lock=[$gotLock]"); 247 260 return $gotLock; 248 261 } … … 250 263 private function resetLock($name, $windowSeconds) { 251 264 $settingName = $this->getLockName($name); 252 $this->setSettingValue($settingName, time() + $windowSeconds); 265 $attemptedNewValue = time() + $windowSeconds; 266 $this->log('debug', "BEGIN resetLock $settingName for window $windowSeconds (setting to=[$attemptedNewValue])"); 267 $this->setSettingValue($settingName, $attemptedNewValue, false); 268 $newValue = $this->getSettingValue($settingName, true); 269 $this->log('debug', "END resetLock $settingName for window $windowSeconds. New value=[$newValue]"); 253 270 } 254 271 … … 259 276 private function clearLock($name) { 260 277 $settingName = $this->getLockName($name); 261 $this->setSettingValue($settingName, null); 278 $this->log('debug', "BEGIN clearLock $settingName"); 279 $this->setSettingValue($settingName, null, false); 280 $wasCleared = $this->getSettingValue($settingName, true); 281 $this->log('debug', "END clearLock $settingName. New value=[$wasCleared]"); 282 } 283 284 public function removeSendCommentsLock() { 285 $this->clearLock("commandSendComments"); 262 286 } 263 287 … … 273 297 return 'LOCK_WAITING'; 274 298 } 275 $lastSendDate = $this->getSettingValue('fastcomments_stream_last_send_timestamp' );276 $lastSentId = $this->getSettingValue('fastcomments_stream_last_send_id' );299 $lastSendDate = $this->getSettingValue('fastcomments_stream_last_send_timestamp', true); 300 $lastSentId = $this->getSettingValue('fastcomments_stream_last_send_id', true); 277 301 $commentCount = $this->getCommentCount($lastSentId ? $lastSentId : -1); 278 302 if ($commentCount == 0) { … … 329 353 $countRemaining = $countRemainingIfSuccessful; 330 354 $fromDateTime = $lastCommentFromDateTime; 331 $this->setSettingValue('fastcomments_stream_last_send_timestamp', $fromDateTime );332 $this->setSettingValue('fastcomments_stream_last_send_id', $lastComment['externalId'] );355 $this->setSettingValue('fastcomments_stream_last_send_timestamp', $fromDateTime, false); 356 $this->setSettingValue('fastcomments_stream_last_send_id', $lastComment['externalId'], false); 333 357 if ($countRemaining <= 0) { 334 358 $this->setSetupDone(); … … 358 382 $this->log('error', "Failed to get comments to send: status=[$status] comments=[$comments]"); 359 383 } 360 $this->resetLock("commandSendComments", 1); // Instead of calling clearLock, prevent race condition on page refresh during setup where same chunk can get submitted twice. Not the worst thing in the world but looks weird to user. 384 // setting the lock to 1 second out causes each chunk upload to wait 59 seconds... so let's always clear it 385 // we fixed issues with lock state being cached, and added a de-dupe mechanism in the backend to detect duplicate chunks, so race conditions should not be an issue. 386 $this->clearLock("commandSendComments"); 361 387 $this->log('debug', 'Done sending comments'); 362 388 return $countSynced; -
fastcomments/trunk/core/FastCommentsWordPressIntegration.php
r2744374 r2771905 152 152 } 153 153 154 public function getSettingValue($settingName) { 154 public function getSettingValue($settingName, $fromDB = false) { 155 if ($fromDB) { 156 wp_cache_delete($settingName, 'options'); 157 } 155 158 return get_option($settingName); 156 159 } 157 160 158 public function setSettingValue($settingName, $settingValue) { 159 update_option($settingName, $settingValue); 161 public function setSettingValue($settingName, $settingValue, $autoload = true) { 162 if ($settingValue === null) { 163 delete_option($settingName); 164 wp_cache_delete($settingName, 'options'); 165 } else { 166 update_option($settingName, $settingValue); 167 } 160 168 } 161 169 -
fastcomments/trunk/fastcomments-wordpress-plugin.php
r2768103 r2771905 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.12. 46 Version: 3.12.5 7 7 Author: winrid @ FastComments 8 8 License: GPL-2.0+ … … 14 14 } 15 15 16 $FASTCOMMENTS_VERSION = 3.12 4;16 $FASTCOMMENTS_VERSION = 3.125; 17 17 18 18 require_once plugin_dir_path(__FILE__) . 'admin/fastcomments-admin.php'; -
fastcomments/trunk/uninstall.php
r2744374 r2771905 10 10 require_once plugin_dir_path(__FILE__) . 'core/FastCommentsWordPressIntegration.php'; 11 11 12 $fastcomments = new FastCommentsWordPressIntegration(); 13 $fastcomments->removeSendCommentsLock(); 14 12 15 delete_option( 'fastcomments_tenant_id' ); 13 16 delete_option( 'fastcomments_connection_token' ); … … 19 22 delete_option( 'fastcomments_cdn' ); 20 23 21 $fastcomments = new FastCommentsWordPressIntegration(); 24 22 25 $fastcomments->deactivate();
Note: See TracChangeset
for help on using the changeset viewer.