Skip to content

Commit e5b0260

Browse files
committed
use validator for attachment ping
1 parent 8a70cfb commit e5b0260

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-sync-queue.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function is_running() {
190190
* @return array
191191
*/
192192
public function get_queue_status() {
193-
$queue = $this->get_queue();
193+
$queue = $this->validate_queue();
194194
$pending = 0;
195195
foreach ( $this->threads as $thread ) {
196196
$pending += count( $queue[ $thread ] );
@@ -234,6 +234,8 @@ public function get_queue_status() {
234234

235235
/**
236236
* Validate the queue is up to date and populate with unsynced assets.
237+
*
238+
* @return array Validated Queue.
237239
*/
238240
public function validate_queue() {
239241

@@ -281,10 +283,16 @@ public function validate_queue() {
281283
$chunks = array_chunk( $ids, $chunk_size );
282284
foreach ( $chunks as $index => $chunk ) {
283285
$queue[ $this->threads[ $index ] ] = $chunk;
286+
// Check thread is still running.
287+
if ( $this->is_running() && ! $this->thread_running( $this->threads[ $index ] ) ) {
288+
$this->start_thread( $this->threads[ $index ] );
289+
}
284290
}
285291
}
286292

287293
$this->set_queue( $queue );
294+
295+
return $queue;
288296
}
289297

290298
/**

0 commit comments

Comments
 (0)