Jake Vanderwerf
2026-02-04 2127b1bdd73ecd2423e443992da4b442f5a3c1a3
inc/managers/queue/Storage.php
@@ -34,24 +34,19 @@
   {
      $now = current_time('mysql');
      $rows = $this->wpdb->get_results($this->wpdb->prepare("
         SELECT oq.* FROM {$this->table} oq
         WHERE oq.state IN ('pending', 'scheduled')
           AND oq.scheduled_at <= %s
           AND NOT EXISTS (
              SELECT 1
              FROM JSON_TABLE(
                 COALESCE(NULLIF(oq.dependencies, 'null'), '[]'),
                 '\$[*]' COLUMNS (dep_id VARCHAR(64) PATH '\$')
              ) AS deps
              JOIN {$this->table} dep ON dep.id = deps.dep_id
              WHERE dep.state != 'completed'
                OR dep.outcome NOT IN ('success', 'partial')
           )
         ORDER BY FIELD(oq.priority, 'high', 'normal', 'low'), oq.scheduled_at
      $rows = $this->wpdb->get_results(
         $this->wpdb->prepare("
            SELECT *
            FROM {$this->table}
            WHERE state IN ('pending', 'scheduled')
              AND scheduled_at <= %s
            ORDER BY
              FIELD(priority, 'high', 'normal', 'low'),
              scheduled_at
         LIMIT %d
         FOR UPDATE SKIP LOCKED
      ", $now, $limit));
        ", $now, $limit)
      );
      return array_map([$this, 'rowToOperation'], $rows ?: []);
   }