wp-queue
wp-queue copied to clipboard
Queue processing issue
I have a problem with this library. Jobs are added to the database but are not performed. Single event is created with name wp_queue_connections_databaseconnection and after few moments it disappears from Event list. My code:
$items = [
'test 1',
'test 2',
'test 3',
'test 4',
];
foreach ($items as $item) {
wp_queue()->push(new \Some_Class\Backup_Job($item));
}
wp_queue()->cron();
Job class:
namespace Some_Class;
use WP_Queue\Job;
class Backup_Job extends Job
{
public $name;
/**
* Backup_Job constructor.
* @param $name
*/
public function __construct($name)
{
$this->name = $name;
}
public function handle()
{
sleep(1);
}
}
Jobs in DB:
Jobs are not fail. Just stuck in wp_queue_jobs
Ping :)
Do your jobs get processed when u manually call the worker?
This way you know if it's a problem with WP_Cron or the actual queue.
wp_queue()->worker()->process()
I'm having the exact same issue, even when I manually call wp_queue()->worker()->process()
I should add that it appears my issue was caused by problems in a script called by my Job class. Once I resolved this issue, manually calling the worker appears to have worked. That being said, I feel like this is when it should have been marked as a failed job.