Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
24bb9a6830
16 files changed
+84
-243
No files matched your search
@@ -105,7 +105,7 @@
|
||||
];
|
||||
|
||||
$userId = User::getCurrentUserId();
|
||||
if (!empty($userId)) {
|
||||
if ($userId !== null) {
|
||||
$objectUser = new User($userId);
|
||||
$env['userId'] = $objectUser->getId();
|
||||
$env['userLogin'] = $objectUser->getLogin();
|
||||
@@ -135,38 +135,4 @@
|
||||
|
||||
return $result ?: 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Метод сохранения логов в Sentry
|
||||
*
|
||||
* @param string $sentryMessage Сообщение, передаваемое в Sentry и отображающееся как заголовок Issue
|
||||
* @param string $sentryErrorLevel Уровень события Sentry (FATAL, ERROR, WARNING, INFO, DEBUG)
|
||||
* @param array $sentryData Массив данных лога
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function logToSentry(
|
||||
string $sentryMessage,
|
||||
string $sentryErrorLevel = 'DEBUG',
|
||||
array $sentryData = []
|
||||
): bool {
|
||||
$sentryErrorLevelArray = ['FATAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'];
|
||||
|
||||
if (empty(trim($sentryMessage))
|
||||
|| !in_array($sentryErrorLevel, $sentryErrorLevelArray)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($sentryData) && count($sentryData) > 0) {
|
||||
\Sentry\configureScope(function (\Sentry\State\Scope $sentryScope) use ($sentryData) {
|
||||
foreach ($sentryData as $paramName => $paramValue) {
|
||||
$sentryScope->setExtra($paramName, $paramValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
\Sentry\captureMessage($sentryMessage, \Sentry\Severity::$sentryErrorLevel());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (c) 2022 Roman Grinko <rsgrinko@gmail.com>
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Класс реестра
|
||||
*/
|
||||
|
||||
namespace Core\Helpers;
|
||||
|
||||
class Registry
|
||||
{
|
||||
private static $_storage = [];
|
||||
|
||||
/**
|
||||
* Установка значения
|
||||
*/
|
||||
public static function set($key, $value)
|
||||
{
|
||||
return self::$_storage[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение значения
|
||||
*/
|
||||
public static function get($key, $default = null)
|
||||
{
|
||||
return (isset(self::$_storage[$key])) ? self::$_storage[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаление
|
||||
*/
|
||||
public static function del($key): void
|
||||
{
|
||||
unset(self::$_storage[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Очистка
|
||||
*/
|
||||
public static function flush(): void
|
||||
{
|
||||
self::$_storage = [];
|
||||
}
|
||||
}
|
||||
@@ -390,7 +390,7 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
|
||||
foreach ($res['photos'] as $arImage) {
|
||||
$result[] = [
|
||||
'date' => $arImage['earth_date'],
|
||||
'src' => $arImage['img_src'],
|
||||
'src' => $arImage['img_src'],
|
||||
];
|
||||
}
|
||||
$page++;
|
||||
@@ -401,33 +401,6 @@ DELETE from `jokes` WHERE `jokes`.id not in (SELECT id FROM t_temp);'
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function saveSolImages($sol)
|
||||
{
|
||||
$counter = 0;
|
||||
$files = [];
|
||||
$res = self::getSolImages($sol);
|
||||
sleep(5);
|
||||
|
||||
if (empty($res)) {
|
||||
throw new CoreException('Изображений с ровера за ' . $sol . ' сол нет');
|
||||
}
|
||||
foreach ($res as $arImage) {
|
||||
$folder = 'ftp://admin:j2medit@10.8.0.2/mars/' . $arImage['date'];
|
||||
if (!file_exists($folder)) {
|
||||
if (!mkdir($folder) && !is_dir($folder)) {
|
||||
//throw new CoreException('Папку "' . $folder . '" не удалось создать');
|
||||
}
|
||||
}
|
||||
if (copy($arImage['src'], $folder . '/' . basename($arImage['src']))) {
|
||||
$counter++;
|
||||
$files[] = basename($arImage['src']);
|
||||
//throw new CoreException('Не удалось сохранить файл "' . $folder . '/' . basename($arImage['src']) . '" не удалось создать');
|
||||
}
|
||||
}
|
||||
return ['count' => $counter, 'files' => $files];
|
||||
}
|
||||
|
||||
|
||||
public static function getStory($from = null)
|
||||
{
|
||||
$tableName = 'podslyshano';
|
||||
|
||||
@@ -235,8 +235,10 @@
|
||||
} elseif ($param === 'value') {
|
||||
if (is_numeric($v)) {
|
||||
$result .= $v . ', ';
|
||||
} elseif ($v === null) {
|
||||
$result .= 'NULL, ';
|
||||
} else {
|
||||
$result .= '\'' . addslashes($v) . '\', ';
|
||||
$result .= '\'' . ($v === null ? null : addslashes($v)) . '\', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@
|
||||
* @return \Core\Models\MQResponse
|
||||
* @throws CoreException
|
||||
*/
|
||||
public function massCreateTasks(int $count = 1, ?string $class = null, string $method, ?array $params = null): MQResponse
|
||||
public function massCreateTasks(int $count, ?string $class, string $method, ?array $params = null): MQResponse
|
||||
{
|
||||
if (empty($params)) {
|
||||
$params = [];
|
||||
@@ -438,7 +438,7 @@
|
||||
* @return \Core\Models\MQResponse Идентификатор созданного задания
|
||||
* @throws CoreException
|
||||
*/
|
||||
public function createTask(?string $class = null, string $method, ?array $params = null): MQResponse
|
||||
public function createTask(?string $class, string $method, ?array $params = null): MQResponse
|
||||
{
|
||||
if (empty($params)) {
|
||||
$params = [];
|
||||
|
||||
Reference in new issue
Block a user