From: Christian Weiske Date: Sat, 3 Dec 2016 21:32:08 +0000 (+0100) Subject: Do not crash status page when gearman worker is not registered X-Git-Tag: v0.2.1~1 X-Git-Url: https://git.cweiske.de/phinde.git/commitdiff_plain/6c95d7fe170a54449755a8b571a191a3aaaf954e?hp=cbefad7ddd4927b1bbe225fec540a082c15f5403;ds=sidebyside Do not crash status page when gearman worker is not registered --- diff --git a/src/phinde/Queue.php b/src/phinde/Queue.php index 1033d7a..a8ead3d 100644 --- a/src/phinde/Queue.php +++ b/src/phinde/Queue.php @@ -43,10 +43,14 @@ class Queue $cmd = 'gearadmin --status' . '| grep ' . escapeshellarg($this->queueName); $line = exec($cmd); - - $parts = preg_split('#\s+#', $line); - if (count($parts) !== 4) { - throw new \Exception('gearadmin status line does not have 4 parts'); + if ($line === '') { + //job not registered + $parts = [0, -1, -1, -1]; + } else { + $parts = preg_split('#\s+#', $line); + if (count($parts) !== 4) { + throw new \Exception('gearadmin status line does not have 4 parts'); + } } return array(