| @@ -26,10 +26,10 @@ | ||
| 26 | 26 | $this->cronHook = $this->identifier . '_cron'; |
| 27 | 27 | |
| 28 | 28 | add_filter('cron_schedules', array($this, 'addCronInterval')); |
| 29 | 29 | |
| 30 | - add_action('wp_ajax_' . $this->identifier, array($this, 'handleAsyncRequest')); | |
| 31 | - add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'handleAsyncRequest')); | |
| 30 | + add_action('wp_ajax_' . $this->identifier, array($this, 'maybeHandleAsyncRequest')); | |
| 31 | + add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'maybeHandleAsyncRequest')); | |
| 32 | 32 | add_action($this->cronHook, array($this, 'handleCronHealthcheck')); |
| 33 | 33 | |
| 34 | 34 | $this->init(); |
| 35 | 35 | } |
| @@ -125,8 +125,15 @@ | ||
| 125 | 125 | |
| 126 | 126 | return true; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | + public function maybeHandleAsyncRequest() | |
| 130 | + { | |
| 131 | + check_ajax_referer($this->identifier, 'nonce'); | |
| 132 | + | |
| 133 | + $this->handleAsyncRequest(); | |
| 134 | + } | |
| 135 | + | |
| 129 | 136 | public function handleAsyncRequest() |
| 130 | 137 | { |
| 131 | 138 | session_write_close(); |
| 132 | 139 | if (!$this->isProcessing()) { |
| @@ -215,8 +222,9 @@ | ||
| 215 | 222 | ORDER BY option_name ASC |
| 216 | 223 | LIMIT 1 |
| 217 | 224 | ", $keyPattern); |
| 218 | 225 | |
| 226 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom plugin table; no object cache for these operational queries. | |
| 219 | 227 | $batch = $wpdb->get_row($query); |
| 220 | 228 | |
| 221 | 229 | if (empty($batch)) return array(); |
| 222 | 230 | |
| @@ -253,8 +261,9 @@ | ||
| 253 | 261 | |
| 254 | 262 | $table = $wpdb->options; |
| 255 | 263 | $keyPattern = $this->identifier . '_batch_%'; |
| 256 | 264 | |
| 265 | + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom plugin table; no object cache for these operational queries. | |
| 257 | 266 | return $wpdb->get_results( |
| 258 | 267 | $wpdb->prepare(" |
| 259 | 268 | SELECT option_name |
| 260 | 269 | FROM {$table} |