Do not crash status page when gearman worker is not registered
[phinde.git] / src / phinde / Queue.php
index 1033d7ae3e8344c64483929333e143f96b86f4ab..a8ead3d56d5bc682bbcc24b0c0e00a613acdf0e7 100644 (file)
@@ -43,10 +43,14 @@ class Queue
         $cmd = 'gearadmin --status'
             . '| grep ' . escapeshellarg($this->queueName);
         $line = exec($cmd);
         $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(
         }
 
         return array(