Plugin Directory


Ignore:
Timestamp:
10/25/2026 06:29:16 AM (23 hours ago)
Author:
avakodeforge
Message:

Release 1.3.0 (trunk + tag; see readme changelog)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • langforge/trunk/includes/class-forge-queue.php

    r3739707 r3764005  
    121121        ]);
    122122
    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')) {
    126159            spawn_cron();
    127160        }
    128 
    129         return $inserted ? $wpdb->insert_id : false;
    130161    }
    131162
    … …  
    282313    public function ajax_status() {
    283314        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);
    285316
    286317        global $wpdb;
    … …  
    459490 * account binding, the Pro stamp and the Connect error list (Forge_Wporg_Disabled_Connect),
    460491 * 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.
    471504 */
    472505    const SUITE_KEYS = [
    … …  
    483516                'forge_telemetry_last_heartbeat',
    484517                'forge_telemetry_dedup',
     518                'forge_mcp_settings',
     519                'forge_mcp_log',
     520                'forge_mcp_log_refused',
    485521            ],
    486522            'cron'       => ['forge_telemetry_flush'],
    487523            'transients' => ['forge_credits_pricing'],
    488             'prefixes'   => ['forge_credits_'],
     524            'prefixes'   => ['forge_credits_', 'forge_mcp_rl_'],
    489525            'user_meta'  => [],
    490526        ],
    … …  
    549585
    550586        delete_option('forge_license_last_pro_at');
     587        delete_option($slug . '_license_last_pro_at');
    551588
    552589        if (!$alone) {
Note: See TracChangeset for help on using the changeset viewer.