From 7f05051dc73c2a7b710a6f001a2c9d7764ac1056 Mon Sep 17 00:00:00 2001 From: Alexandre Russo Date: Wed, 21 May 2014 11:08:45 +0200 Subject: [PATCH] PHPCI/Plugin/XMPP.php : Add test on empty recipients list and add test to check that all command was successful --- PHPCI/Plugin/XMPP.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/PHPCI/Plugin/XMPP.php b/PHPCI/Plugin/XMPP.php index 2fb3ae63..9bef3402 100644 --- a/PHPCI/Plugin/XMPP.php +++ b/PHPCI/Plugin/XMPP.php @@ -151,6 +151,13 @@ class XMPP implements \PHPCI\Plugin return false; } + /* + * Without recipients we can't send notification + */ + if (count($this->recipients) == 0) { + return false; + } + /* * Try to build conf file */ @@ -181,13 +188,16 @@ class XMPP implements \PHPCI\Plugin /* * Send XMPP notification for all recipients */ - $success = false; + $success = array() foreach($this->recipients as $recipient) { - $success = $this->phpci->executeCommand('echo %s | ' . $sendxmpp . - ' %s %s', $message, $tls, $recipients); + if($cmd = $this->phpci->executeCommand('echo %s | ' . $sendxmpp . + ' %s %s', $message, $tls, $recipients)) { + $success[] = $cmd; + } + print $this->phpci->getLastOutput(); } - return $success; + return (count($success) === count($this->recipients)); } }