fix: ServerShell fails if SimpleBackgroundJobs config does not exists

pull/7984/head
Luciano Righetti 2021-11-22 09:49:34 +01:00
parent fb5a196f63
commit 5316766205
1 changed files with 3 additions and 12 deletions

View File

@ -12,17 +12,8 @@ require_once 'AppShell.php';
*/
class ServerShell extends AppShell
{
/** @var BackgroundJobsTool */
private $BackgroundJobsTool;
public $uses = array('Server', 'Task', 'Job', 'User', 'Feed');
public function initialize(): void
{
parent::initialize();
$this->BackgroundJobsTool = new BackgroundJobsTool(Configure::read('SimpleBackgroundJobs'));
}
public function list()
{
$servers = $this->Server->find('all', [
@ -89,7 +80,7 @@ class ServerShell extends AppShell
foreach ($servers as $serverId => $serverName) {
$backgroundJobId = $this->BackgroundJobsTool->enqueue(
$backgroundJobId = $this->Server->getBackgroundJobsTool()->enqueue(
BackgroundJobsTool::DEFAULT_QUEUE,
BackgroundJobsTool::CMD_SERVER,
[
@ -199,7 +190,7 @@ class ServerShell extends AppShell
foreach ($servers as $serverId => $serverName) {
$jobId = $this->BackgroundJobsTool->enqueue(
$jobId = $this->Server->getBackgroundJobsTool()->enqueue(
BackgroundJobsTool::DEFAULT_QUEUE,
BackgroundJobsTool::CMD_SERVER,
[
@ -319,7 +310,7 @@ class ServerShell extends AppShell
foreach ($servers as $serverId => $serverName) {
$jobId = $this->BackgroundJobsTool->enqueue(
$jobId = $this->Server->getBackgroundJobsTool()->enqueue(
BackgroundJobsTool::DEFAULT_QUEUE,
BackgroundJobsTool::CMD_SERVER,
[