diff --git a/admin/register.php b/admin/register.php index 7237a83..48352a2 100644 --- a/admin/register.php +++ b/admin/register.php @@ -7,7 +7,7 @@ if (User::isAuthorized()) { header('Location: index.php'); } else { $arErrors = []; - if ($_REQUEST['send'] === 'Y') { + if (!empty($_REQUEST['send']) && $_REQUEST['send'] === 'Y') { if (empty($_REQUEST['login'])) { $arErrors[] = 'Логин не задан'; diff --git a/core/bootstrap.php b/core/bootstrap.php index 571abf1..47cc855 100644 --- a/core/bootstrap.php +++ b/core/bootstrap.php @@ -18,9 +18,9 @@ ); Sentry\configureScope(function (Sentry\State\Scope $sentryScope) { - $sentryScope->setExtra('user_id', $_SESSION['id']); - $sentryScope->setExtra('user_login', $_SESSION['login']); - $sentryScope->setExtra('user_token', $_SESSION['token']); + $sentryScope->setExtra('user_id', $_SESSION['id'] ?: ''); + $sentryScope->setExtra('user_login', $_SESSION['login'] ?: ''); + $sentryScope->setExtra('user_token', $_SESSION['token'] ?: ''); }); /* try { diff --git a/core/lib/Core/Models/MQ.class.php b/core/lib/Core/Models/MQ.class.php index 6ac765c..292fabe 100644 --- a/core/lib/Core/Models/MQ.class.php +++ b/core/lib/Core/Models/MQ.class.php @@ -19,9 +19,9 @@ $this->DB = DB::getInstance(); } - public static function test($params): void + public static function test($name, $age): int { - Log::logToFile('Тестирование сработало видимо', 'MQ_test.log', $params); + return Log::logToFile('Тестирование сработало видимо.', 'MQ_test.log', func_get_args()); } @@ -32,7 +32,7 @@ 'active' => 'N', 'in_progress' => 'N', 'attempts' => '0', - 'class' => str_replace('\\', '\\\\\\\\', $class), + 'class' => str_replace('\\', '\\\\', $class), 'method' => $method, 'params' => json_encode($params, JSON_UNESCAPED_UNICODE), ] @@ -42,6 +42,8 @@ public function execute(int $taskId) { $arTask = $this->DB->getItem(self::TABLE, ['id' => $taskId]); + $arTask['class'] = str_replace('\\\\', '\\', $arTask['class']); + $arTask['params'] = json_decode($arTask['params'], true); $this->DB->update( self::TABLE, ['id' => $taskId], [ 'active' => 'Y', @@ -49,10 +51,19 @@ 'attempts' => ((int)$arTask['attempts'] + 1), ] ); - //echo '
'.print_r($arTask, true).'
';die(); + try { - $arTask['class']::$arTask['method'](); - $this->DB->remove(self::TABLE, ['id' => $taskId]); + + $result = call_user_func_array($arTask['class'] . '::' . $arTask['method'], $arTask['params']); + //$this->DB->remove(self::TABLE, ['id' => $taskId]); + $this->DB->update( + self::TABLE, ['id' => $taskId], [ + 'active' => 'N', + 'in_progress' => 'N', + 'executed' => 'Y', + 'response' => json_encode($result, JSON_UNESCAPED_UNICODE), + ] + ); } catch (\Throwable $t) { $this->DB->update( self::TABLE, ['id' => $taskId], [ @@ -61,6 +72,7 @@ 'response' => $t->getMessage(), ] ); + echo $t->getMessage(); } } } \ No newline at end of file