Skip to content

Commit

Permalink
Merge pull request #42 from glenouvel/fix_wrong_channel_name
Browse files Browse the repository at this point in the history
Ticket 354099 - fix wrong channelName when channel is locked
  • Loading branch information
glenouvel committed Feb 13, 2017
2 parents 0bb6a0e + 8521cca commit dbf20e0
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions Command/LoggerStateChannelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,41 @@ protected function execute(InputInterface $input, OutputInterface $output)
foreach ($locks as $lock) {
if ($lock->isCommandLocked()) {
foreach ($this->channels as $key => $channel) {
$this->loadChannelInfomation($key, $lock, $channel);
}
if ($this->isLockedChannelInfomation($key, $lock, $channel, $output)) {

$dateWithMaxTime = $lock->getLockedAt();

$dateWithMaxTime = $lock->getLockedAt();
$dateWithMaxTime->add(new DateInterval('PT' . $this->timeLimit . 'S'));
if (new \DateTime() > ($dateWithMaxTime)) {
$this->notifier->process($this->channelName);
$time = $channel['duration_limit_per_run'] + $this->extraTime;
$dateWithMaxTime->add(
new DateInterval('PT' . $time . 'S')
);
if (new \DateTime() > ($dateWithMaxTime)) {
$this->notifier->process($key);
}

break;
}
}


}
}
}

/**
* @param string $key
* @param Lock $lock
* @param array $channel
* @param $key
* @param Lock $lock
* @param $channel
* @return bool
*/
private function loadChannelInfomation($key, Lock $lock, $channel)
private function isLockedChannelInfomation($key, Lock $lock, $channel)
{
$this->channelName = $key;
$this->timeLimit = $channel['duration_limit_per_run'] + $this->extraTime;

if (preg_match(sprintf('/^%s/', $key), $lock->getChannel()) && true === $channel['dynamic']) {
$this->channelName = $lock->getChannel();
$this->timeLimit = $channel['duration_limit_per_run'] + $this->extraTime;
if (preg_match(sprintf('/^%s/', $key), $lock->getChannel()) && true === $channel['dynamic'] || $key == $lock->getChannel() && false === $channel['dynamic']) {

return true;
}

return false;
}
}

0 comments on commit dbf20e0

Please sign in to comment.