| @@ -110,8 +110,23 @@ | ||
| 110 | 110 | |
| 111 | 111 | return (string) $result === '1'; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | + public function getStaleProcessingJob(int $timeoutSeconds = 120): ?object | |
| 115 | + { | |
| 116 | + global $wpdb; | |
| 117 | + | |
| 118 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Custom queue table; identifier from the WordPress prefix, values prepared. | |
| 119 | + return $wpdb->get_row($wpdb->prepare( | |
| 120 | + "SELECT id, started_at FROM {$this->jobManagerTableName} | |
| 121 | + WHERE status = 'processing' | |
| 122 | + AND started_at IS NOT NULL | |
| 123 | + AND started_at < %d | |
| 124 | + ORDER BY started_at ASC, id ASC LIMIT 1", | |
| 125 | + time() - $timeoutSeconds | |
| 126 | + )); | |
| 127 | + } | |
| 128 | + | |
| 114 | 129 | public function getJob($where = array()) |
| 115 | 130 | { |
| 116 | 131 | global $wpdb; |
| 117 | 132 | |