diff --git a/VERSION b/VERSION index 293fbd1..5103369 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.2.4 +v3.2.3 diff --git a/controllers/internals/ExpressionProvider.php b/controllers/internals/ExpressionProvider.php index 9d056ab..7ee1f9c 100644 --- a/controllers/internals/ExpressionProvider.php +++ b/controllers/internals/ExpressionProvider.php @@ -11,7 +11,6 @@ namespace controllers\internals; -use DateTime; use Symfony\Component\ExpressionLanguage\ExpressionFunction; use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; @@ -38,34 +37,15 @@ class ExpressionProvider implements ExpressionFunctionProviderInterface return isset($var); }); - //Check if today is birthday given a birthdate as DateTime - $is_birthday = new ExpressionFunction('is_birthday', function ($birthdate) - { - return sprintf('isset(%1$s) && is_a(%1$s, \'DateTime\') && %1$s->format(\'m-d\') == (new \\DateTime())->format(\'m-d\')', $birthdate); - }, function ($arguments, DateTime $birthdate) - { - if (!($birthdate ?? false)) - { - return false; - } - - return $birthdate->format('m-d') == (new DateTime())->format('m-d'); - }); - return [ $neutralized_constant, $exists, - $is_birthday, ExpressionFunction::fromPhp('mb_strtolower', 'lower'), ExpressionFunction::fromPhp('mb_strtoupper', 'upper'), ExpressionFunction::fromPhp('mb_substr', 'substr'), ExpressionFunction::fromPhp('mb_strlen', 'strlen'), ExpressionFunction::fromPhp('abs', 'abs'), - ExpressionFunction::fromPhp('date_create', 'date'), - ExpressionFunction::fromPhp('date_create_from_format', 'date_from_format'), - ExpressionFunction::fromPhp('intval', 'intval'), - ExpressionFunction::fromPhp('boolval', 'boolval'), - ExpressionFunction::fromPhp('count', 'count'), + ExpressionFunction::fromPhp('strtotime', 'date'), ]; } } diff --git a/controllers/internals/Ruler.php b/controllers/internals/Ruler.php index 0dc3103..1682ef4 100644 --- a/controllers/internals/Ruler.php +++ b/controllers/internals/Ruler.php @@ -43,15 +43,18 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; { try { - //Use @ to hide notices on non defined vars - @$this->expression_language->parse($condition, array_keys($data)); + $this->expression_language->parse($condition, array_keys($data)); return true; } - catch (\Throwable $t) //Catch both, exceptions and php error + catch (\Exception $e) { return false; } + catch (\Throwable $t) + { + //Just ignore non critical php warning and notice + } } /** @@ -66,12 +69,11 @@ use Symfony\Component\ExpressionLanguage\ExpressionLanguage; { try { - //Use @ to hide notices on non defined vars @$result = $this->expression_language->evaluate($condition, $data); return (bool) $result; } - catch (\Throwable $t) //Catch both, exceptions and php error + catch (\Exception $e) { return null; } diff --git a/daemons/Phone.php b/daemons/Phone.php index a6c7ba9..1be7856 100644 --- a/daemons/Phone.php +++ b/daemons/Phone.php @@ -20,8 +20,6 @@ use Monolog\Logger; class Phone extends AbstractDaemon { private $max_inactivity = 5 * 60; - private $read_delay = 20 / 0.5; - private $read_tick = 0; private $msg_queue; private $msg_queue_id; private $webhook_queue; @@ -58,20 +56,13 @@ class Phone extends AbstractDaemon { usleep(0.5 * 1000000); //Micro sleep for perfs - $this->read_tick += 1; - $this->bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, 'UTF8'); //Send smss in queue $this->send_smss(); - //Read only every x ticks (x/2 seconds) to prevent too many call - if ($this->read_tick >= $this->read_delay) - { - //Read received smss - $this->read_smss(); - $this->read_tick = 0; - } + //Read received smss + $this->read_smss(); //Stop after 5 minutes of inactivity to avoid useless daemon if ((microtime(true) - $this->last_message_at) > $this->max_inactivity)