Skip to content

Commit b6dd6b7

Browse files
committed
Streamline WP_Background_Process::is_queued() and WP_Background_Process::is_queue_empty()
1 parent f172c83 commit b6dd6b7

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

classes/wp-background-process.php

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,7 @@ protected function resumed() {
257257
* @return bool
258258
*/
259259
public function is_queued() {
260-
$batch = $this->get_batch();
261-
262-
if ( empty( $batch ) ) {
263-
return false;
264-
}
265-
266-
return true;
260+
return ! $this->is_queue_empty();
267261
}
268262

269263
/**
@@ -349,27 +343,7 @@ public function maybe_handle() {
349343
* @return bool
350344
*/
351345
protected function is_queue_empty() {
352-
global $wpdb;
353-
354-
$table = $wpdb->options;
355-
$column = 'option_name';
356-
357-
if ( is_multisite() ) {
358-
$table = $wpdb->sitemeta;
359-
$column = 'meta_key';
360-
}
361-
362-
$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';
363-
364-
$sql = '
365-
SELECT COUNT(*)
366-
FROM ' . $table . '
367-
WHERE ' . $column . ' LIKE %s
368-
';
369-
370-
$count = $wpdb->get_var( $wpdb->prepare( $sql, $key ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
371-
372-
return ! ( $count > 0 );
346+
return empty( $this->get_batch() );
373347
}
374348

375349
/**

0 commit comments

Comments
 (0)