← All changes
|
customer-sync-requests/class-metasync-sync-requests.php
+10
-6
2.6.23
→
2.7.1
View file →
| @@ -87,10 +87,10 @@ | ||
| 87 | 87 | $_throttle = Metasync::get_heartbeat_throttle(); |
| 88 | 88 | $last_hb_request_time = $_throttle['last_heart_beat'] ?? 0; |
| 89 | 89 | |
| 90 | 90 | # PR3: Throttle depends on state — burst (KEY_PENDING within 30 min) allows 30s; else 5 min |
| 91 | - $is_heartbeat = ($context === 'heartbeat') || filter_var($_POST['is_heart_beat'] ?? false, FILTER_VALIDATE_BOOLEAN); | |
| 92 | - $is_burst = !empty($_POST['is_burst']); | |
| 91 | + $is_heartbeat = ($context === 'heartbeat') || filter_var($_POST['is_heart_beat'] ?? false, FILTER_VALIDATE_BOOLEAN); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only throttle flags, callers are already authorized | |
| 92 | + $is_burst = !empty($_POST['is_burst']); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- read-only throttle flags, callers are already authorized | |
| 93 | 93 | $heartbeat_state = $metasync_options['general']['heartbeat_state'] ?? ''; |
| 94 | 94 | $state_changed_at = (int) ($metasync_options['general']['heartbeat_state_changed_at'] ?? 0); |
| 95 | 95 | $burst_window_end = $state_changed_at + (30 * 60); // 30 min cap |
| 96 | 96 | $in_burst_window = ($heartbeat_state === 'KEY_PENDING' && $burst_window_end > time()); |
| @@ -182,8 +182,12 @@ | ||
| 182 | 182 | 'permalink_structure'=>((($current_permalink_structure == '/%post_id%/' || $current_permalink_structure == '') && $current_rewrite_rules == '')?false:true), |
| 183 | 183 | 'otto_pixel_uuid' => $general_options['otto_pixel_uuid'] ?? '', |
| 184 | 184 | ]; |
| 185 | 185 | |
| 186 | + if (Metasync_Headless_Config::is_active()) { | |
| 187 | + $payload['frontend_domain'] = Metasync_Headless_Config::get_frontend_domain(); | |
| 188 | + } | |
| 189 | + | |
| 186 | 190 | # append login auth token to payload |
| 187 | 191 | if(!empty($token)){ |
| 188 | 192 | $payload['login_auth_token'] = $token; |
| 189 | 193 | } |
| @@ -201,9 +205,9 @@ | ||
| 201 | 205 | $response = wp_remote_post($apiUrl, $data); |
| 202 | 206 | |
| 203 | 207 | # PERFORMANCE OPTIMIZATION: Handle timeout and connection errors |
| 204 | 208 | if (is_wp_error($response)) { |
| 205 | - error_log('MetaSync: Heartbeat sync failed: ' . $response->get_error_message()); | |
| 209 | + error_log('MetaSync: Heartbeat sync failed: ' . $response->get_error_message()); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- genuine failure path, bounded, no secrets | |
| 206 | 210 | $this->saveHeartBeatError('heartbeat', 'Connection error: ' . $response->get_error_message(), array(1), 0); |
| 207 | 211 | return; |
| 208 | 212 | } |
| 209 | 213 | |
| @@ -229,13 +233,13 @@ | ||
| 229 | 233 | $response_uuid = sanitize_text_field($response_body['otto_pixel_uuid']); |
| 230 | 234 | if (!empty($response_body['uuid_mismatch'])) { |
| 231 | 235 | # Domain clone: backend says local UUID is wrong for this domain |
| 232 | 236 | $_sync_updates['otto_pixel_uuid'] = $response_uuid; |
| 233 | - error_log('MetaSync: UUID corrected from ' . $current_uuid . ' to ' . $response_uuid . ' (domain clone detected)'); | |
| 237 | + error_log('MetaSync: UUID corrected from ' . $current_uuid . ' to ' . $response_uuid . ' (domain clone detected)'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- genuine failure path, bounded, no secrets | |
| 234 | 238 | } elseif (empty($current_uuid)) { |
| 235 | 239 | # Self-heal: SSO callback failed but API key was saved; recover UUID from heartbeat |
| 236 | 240 | $_sync_updates['otto_pixel_uuid'] = $response_uuid; |
| 237 | - error_log('MetaSync: UUID set from heartbeat response (self-heal after SSO callback missed)'); | |
| 241 | + error_log('MetaSync: UUID set from heartbeat response (self-heal after SSO callback missed)'); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- genuine failure path, bounded, no secrets | |
| 238 | 242 | } |
| 239 | 243 | } |
| 240 | 244 | |
| 241 | 245 | # PR3: Server confirmation → transition to CONNECTED (backend sends registered: true; accept both for compatibility) |
| @@ -456,9 +460,9 @@ | ||
| 456 | 460 | $response = wp_remote_get($url, $args); |
| 457 | 461 | |
| 458 | 462 | # PERFORMANCE OPTIMIZATION: Handle timeout and connection errors |
| 459 | 463 | if (is_wp_error($response)) { |
| 460 | - error_log('MetaSync: White label user sync failed: ' . $response->get_error_message()); | |
| 464 | + error_log('MetaSync: White label user sync failed: ' . $response->get_error_message()); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- genuine failure path, bounded, no secrets | |
| 461 | 465 | return; |
| 462 | 466 | } |
| 463 | 467 | |
| 464 | 468 | $body = wp_remote_retrieve_body($response); |