Changeset 3764005 for langforge/trunk/includes/class-forge-queue.php
- Timestamp:
- 10/25/2026 06:29:16 AM (23 hours ago)
- File:
-
- 1 edited
-
langforge/trunk/includes/class-forge-queue.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
langforge/trunk/includes/class-forge-queue.php
r3739707 r3764005 121 121 ]); 122 122 123 if ($inserted) { 124 // Nudge WP-Cron so jobs start even on local/MAMP environments 125 // where no external HTTP hits trigger cron. 123 if (!$inserted) { 124 return false; 125 } 126 127 // Read before anything else writes: spawn_cron INSERTs the doing_cron 128 // transient into wp_options, and insert_id is the last row of any table 129 // (BUG-SUITE-QUEUE-01: callers were handed that row's id). 130 $id = (int) $wpdb->insert_id; 131 132 self::nudge_cron_at_shutdown(); 133 134 return $id; 135 } 136 137 /** @var bool a cron nudge is already waiting for the end of this request */ 138 private static $nudge_pending = false; 139 140 /** 141 * Nudge WP-Cron so jobs start even on local/MAMP environments where no 142 * external HTTP hits trigger cron. At the end of the request, not inside 143 * dispatch: the loopback request spawn_cron sends can run the job before 144 * the caller has stored its id and shown "queued". Once per request, however 145 * many jobs were queued. 146 */ 147 private static function nudge_cron_at_shutdown(): void { 148 if (self::$nudge_pending) { 149 return; 150 } 151 self::$nudge_pending = true; 152 add_action('shutdown', [__CLASS__, 'nudge_cron']); 153 } 154 155 /** `shutdown` handler of nudge_cron_at_shutdown. */ 156 public static function nudge_cron(): void { 157 self::$nudge_pending = false; 158 if (function_exists('spawn_cron')) { 126 159 spawn_cron(); 127 160 } 128 129 return $inserted ? $wpdb->insert_id : false;130 161 } 131 162 … … 282 313 public function ajax_status() { 283 314 check_ajax_referer('forge_queue_nonce', 'nonce'); 284 if (!current_user_can('manage_options')) wp_send_json_error( );315 if (!current_user_can('manage_options')) wp_send_json_error(['message' => __('Forbidden', 'langforge')], 403); 285 316 286 317 global $wpdb; … … 459 490 * account binding, the Pro stamp and the Connect error list (Forge_Wporg_Disabled_Connect), 460 491 * the seven statistics options with their hourly event (Forge_Telemetry), the 461 * credits widget's caches. 'free' is the Free plugins' classes: the 462 * ever-connected flag, the health history and the feedback timestamp (the 463 * dashboard and feedback widget), the queue version, table and events (this 464 * class), the deactivation lock, the feedback and Pro-tip user meta. A new 465 * option, transient, event or meta key in a shared class goes on this list, 466 * or it outlives the last Forge plugin. 467 * 468 * 'prefixes' are the transients whose name goes on with a product slug or a 469 * user id (`forge_credits_<slug>_<user>`, `forge_deact_lock_<user>`): the 470 * only names removed by prefix, and the prefixes are whole words. 492 * credits widget's caches, the MCP layer's settings, its two journals and the 493 * rate counters of agents' calls (Forge_Mcp). 'free' is the Free plugins' 494 * classes: the ever-connected flag, the health history and the feedback 495 * timestamp (the dashboard and feedback widget), the queue version, table and 496 * events (this class), the deactivation lock, the feedback and Pro-tip user 497 * meta. A new option, transient, event or meta key in a shared class goes on 498 * this list, or it outlives the last Forge plugin. 499 * 500 * 'prefixes' are the transients whose name goes on with a product slug, a 501 * user id or a hash (`forge_credits_<slug>_<user>`, `forge_deact_lock_<user>`, 502 * `forge_mcp_rl_<md5>`): the only names removed by prefix, and the prefixes 503 * are whole words. 471 504 */ 472 505 const SUITE_KEYS = [ … … 483 516 'forge_telemetry_last_heartbeat', 484 517 'forge_telemetry_dedup', 518 'forge_mcp_settings', 519 'forge_mcp_log', 520 'forge_mcp_log_refused', 485 521 ], 486 522 'cron' => ['forge_telemetry_flush'], 487 523 'transients' => ['forge_credits_pricing'], 488 'prefixes' => ['forge_credits_' ],524 'prefixes' => ['forge_credits_', 'forge_mcp_rl_'], 489 525 'user_meta' => [], 490 526 ], … … 549 585 550 586 delete_option('forge_license_last_pro_at'); 587 delete_option($slug . '_license_last_pro_at'); 551 588 552 589 if (!$alone) {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)