mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
ref
This commit is contained in:
@@ -128,7 +128,7 @@ class KeysProvider
|
||||
/** @var string|false $response */
|
||||
$response = curl_exec($curl);
|
||||
$error = curl_error($curl);
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE) ?? 0;
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ class Login implements LoginInterface
|
||||
/** @var string|false $response */
|
||||
$response = curl_exec($curl);
|
||||
$error = curl_error($curl);
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE) ?? 0;
|
||||
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ class CalculatorUtil
|
||||
);
|
||||
}
|
||||
|
||||
/** @var ?string $result */
|
||||
$result = bcdiv(
|
||||
$arg1,
|
||||
$arg2,
|
||||
|
||||
@@ -216,7 +216,7 @@ class Client
|
||||
* @return array{
|
||||
* result: array<string,mixed>|string,
|
||||
* code: int,
|
||||
* contentType: string,
|
||||
* contentType: string|false,
|
||||
* header: string,
|
||||
* }
|
||||
* @throws Exception
|
||||
@@ -258,9 +258,9 @@ class Client
|
||||
* @param string $httpMethod
|
||||
* @param array<string,string> $httpHeaders
|
||||
* @return array{
|
||||
* result: array<string,mixed>|string,
|
||||
* result: array<string, mixed>|string,
|
||||
* code: int,
|
||||
* contentType: string,
|
||||
* contentType: string|false,
|
||||
* header: string,
|
||||
* }
|
||||
* @throws Exception
|
||||
@@ -353,25 +353,27 @@ class Client
|
||||
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
|
||||
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
|
||||
|
||||
$responceHeader = substr($response, 0, $headerSize);
|
||||
$responceBody = substr($response, $headerSize);
|
||||
|
||||
$resultArray = null;
|
||||
$responseHeader = substr($response, 0, $headerSize);
|
||||
$responseBody = substr($response, $headerSize);
|
||||
|
||||
if ($curlError = curl_error($ch)) {
|
||||
throw new Exception($curlError);
|
||||
}
|
||||
else {
|
||||
$resultArray = json_decode($responceBody, true);
|
||||
}
|
||||
|
||||
$resultArray = json_decode($responseBody, true);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
/** @var array<string, mixed>|string $result */
|
||||
$result = ($resultArray !== null) ?
|
||||
$resultArray :
|
||||
$responseBody;
|
||||
|
||||
return [
|
||||
'result' => (null !== $resultArray) ? $resultArray : $responceBody,
|
||||
'result' => $result,
|
||||
'code' => intval($httpCode),
|
||||
'contentType' => $contentType,
|
||||
'header' => $responceHeader,
|
||||
'header' => $responseHeader,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -383,9 +385,9 @@ class Client
|
||||
* client_secret?: string,
|
||||
* } $params
|
||||
* @return array{
|
||||
* result: array<string,mixed>|string,
|
||||
* result: array<string, mixed>|string,
|
||||
* code: int,
|
||||
* contentType: string,
|
||||
* contentType: string|false,
|
||||
* header: string,
|
||||
* }
|
||||
* @throws Exception
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\Formula\Functions\EntityGroup;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\Formula\Functions\EntityGroup;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Espo\Core\Formula\Functions\EntityGroup;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Formula\Functions\RecordGroup;
|
||||
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\ORM\EntityManager;
|
||||
|
||||
use Espo\Core\Formula\{
|
||||
Functions\BaseFunction,
|
||||
|
||||
@@ -105,13 +105,13 @@ class EspoRotatingFileHandler extends EspoFileHandler
|
||||
$fileInfo = pathinfo($this->filename);
|
||||
|
||||
$timedFilename = str_replace(
|
||||
array('{filename}', '{date}'),
|
||||
array($fileInfo['filename'], date($this->dateFormat)),
|
||||
$fileInfo['dirname'] . '/' . $this->filenameFormat
|
||||
['{filename}', '{date}'],
|
||||
[$fileInfo['filename'], date($this->dateFormat)],
|
||||
($fileInfo['dirname'] ?? '') . '/' . $this->filenameFormat
|
||||
);
|
||||
|
||||
if (!empty($fileInfo['extension'])) {
|
||||
$timedFilename .= '.'.$fileInfo['extension'];
|
||||
$timedFilename .= '.' . $fileInfo['extension'];
|
||||
}
|
||||
|
||||
return $timedFilename;
|
||||
|
||||
@@ -66,7 +66,6 @@ class MailMimeParser implements Parser
|
||||
];
|
||||
|
||||
private EntityManager $entityManager;
|
||||
|
||||
private ?WrappeeParser $parser = null;
|
||||
|
||||
/**
|
||||
@@ -337,11 +336,12 @@ class MailMimeParser implements Parser
|
||||
$contentId = trim($contentId, '<>');
|
||||
}
|
||||
|
||||
if ($disposition == 'inline') {
|
||||
if ($disposition === 'inline') {
|
||||
$attachment->set('role', Attachment::ROLE_INLINE_ATTACHMENT);
|
||||
}
|
||||
else {
|
||||
$disposition = 'attachment';
|
||||
|
||||
$attachment->set('role', Attachment::ROLE_ATTACHMENT);
|
||||
}
|
||||
|
||||
@@ -349,23 +349,27 @@ class MailMimeParser implements Parser
|
||||
|
||||
$this->entityManager->saveEntity($attachment);
|
||||
|
||||
if ($disposition == 'attachment') {
|
||||
if ($disposition === 'attachment') {
|
||||
$email->addLinkMultipleId('attachments', $attachment->getId());
|
||||
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->getId();
|
||||
}
|
||||
}
|
||||
else if ($disposition == 'inline') {
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->getId();
|
||||
|
||||
$inlineAttachmentList[] = $attachment;
|
||||
}
|
||||
else {
|
||||
$email->addLinkMultipleId('attachments', $attachment->getId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// inline
|
||||
|
||||
if ($contentId) {
|
||||
$inlineIds[$contentId] = $attachment->getId();
|
||||
|
||||
$inlineAttachmentList[] = $attachment;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$email->addLinkMultipleId('attachments', $attachment->getId());
|
||||
}
|
||||
|
||||
$body = $email->get('body');
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core\Utils;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use stdClass;
|
||||
|
||||
class DataUtil
|
||||
{
|
||||
@@ -114,9 +115,9 @@ class DataUtil
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string|int,mixed>|\stdClass $data
|
||||
* @param array<string|int,mixed>|stdClass $data
|
||||
* @param mixed $needle
|
||||
* @return array<string|int,mixed>|\stdClass
|
||||
* @return array<string|int,mixed>|stdClass
|
||||
*/
|
||||
public static function unsetByValue(&$data, $needle)
|
||||
{
|
||||
@@ -150,25 +151,25 @@ class DataUtil
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array<string,mixed>|\stdClass $data
|
||||
* @param array<string,mixed>|\stdClass $overrideData
|
||||
* @return array<string|int,mixed>|\stdClass
|
||||
* @param array<string, mixed>|stdClass $data
|
||||
* @param array<string, mixed>|stdClass $overrideData
|
||||
* @return array<string|int, mixed>|stdClass
|
||||
*/
|
||||
public static function merge($data, $overrideData)
|
||||
{
|
||||
$appendIdentifier = '__APPEND__';
|
||||
|
||||
if (
|
||||
is_object($data) &&
|
||||
is_object($overrideData) &&
|
||||
get_object_vars($data) === [] &&
|
||||
get_object_vars($overrideData) === []
|
||||
) {
|
||||
return (object) [];
|
||||
}
|
||||
|
||||
if (empty($data) && empty($overrideData)) {
|
||||
if (is_object($data) || is_object($overrideData)) {
|
||||
return (object) [];
|
||||
}
|
||||
else if (is_array($data) || is_array($overrideData)) {
|
||||
return [];
|
||||
}
|
||||
else {
|
||||
return $overrideData;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
if (is_object($overrideData)) {
|
||||
@@ -188,7 +189,8 @@ class DataUtil
|
||||
|
||||
return $data;
|
||||
}
|
||||
else if (is_array($overrideData)) {
|
||||
|
||||
if (is_array($overrideData)) {
|
||||
if (empty($data)) {
|
||||
$data = [];
|
||||
}
|
||||
@@ -203,15 +205,13 @@ class DataUtil
|
||||
|
||||
$data[] = $item;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$data = $overrideData;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
return $overrideData;
|
||||
}
|
||||
|
||||
return $overrideData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ class Base extends \Espo\Core\Utils\Database\Orm\Base
|
||||
|
||||
/**
|
||||
* @param string $allowedItemName
|
||||
* @return ?array<string,mixed>'
|
||||
* @return ?array<string,mixed>
|
||||
*/
|
||||
private function getAllowedAdditionalParam($allowedItemName)
|
||||
{
|
||||
@@ -219,20 +219,23 @@ class Base extends \Espo\Core\Utils\Database\Orm\Base
|
||||
|
||||
$additionalParam = null;
|
||||
|
||||
$linkName = $this->getLinkName();
|
||||
$entityName = $this->getEntityName();
|
||||
|
||||
if (isset($itemLinkParams) && isset($itemForeignLinkParams)) {
|
||||
if (!empty($itemLinkParams) && !is_array($itemLinkParams)) {
|
||||
$additionalParam = $itemLinkParams;
|
||||
} else if (!empty($itemForeignLinkParams) && !is_array($itemForeignLinkParams)) {
|
||||
}
|
||||
else if (!empty($itemForeignLinkParams) && !is_array($itemForeignLinkParams)) {
|
||||
$additionalParam = $itemForeignLinkParams;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/** @var array<int|string, mixed> $itemLinkParams */
|
||||
/** @var array<int|string, mixed> $itemForeignLinkParams */
|
||||
$additionalParam = Util::merge($itemLinkParams, $itemForeignLinkParams);
|
||||
}
|
||||
} else if (isset($itemLinkParams)) {
|
||||
}
|
||||
else if (isset($itemLinkParams)) {
|
||||
$additionalParam = $itemLinkParams;
|
||||
} else if (isset($itemForeignLinkParams)) {
|
||||
}
|
||||
else if (isset($itemForeignLinkParams)) {
|
||||
$additionalParam = $itemForeignLinkParams;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,11 +55,8 @@ class Manager
|
||||
protected string $tmpDir = 'data/tmp';
|
||||
|
||||
protected const RENAME_RETRY_NUMBER = 10;
|
||||
|
||||
protected const RENAME_RETRY_INTERVAL = 0.1;
|
||||
|
||||
protected const GET_SAFE_CONTENTS_RETRY_NUMBER = 10;
|
||||
|
||||
protected const GET_SAFE_CONTENTS_RETRY_INTERVAL = 0.1;
|
||||
|
||||
/**
|
||||
@@ -127,41 +124,49 @@ class Manager
|
||||
|
||||
$cdir = scandir($path) ?: [];
|
||||
|
||||
foreach ($cdir as $key => $value) {
|
||||
if (!in_array($value, [".", ".."])) {
|
||||
$add = false;
|
||||
foreach ($cdir as $value) {
|
||||
if (in_array($value, [".", ".."])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_dir($path . Util::getSeparator() . $value)) {
|
||||
if ($recursively || (is_int($recursively) && $recursively!=0)) {
|
||||
$nextRecursively = is_int($recursively) ? ($recursively-1) : $recursively;
|
||||
$add = false;
|
||||
|
||||
$result[$value] = $this->getFileList(
|
||||
$path . Util::getSeparator() . $value,
|
||||
$nextRecursively,
|
||||
$filter,
|
||||
$onlyFileType
|
||||
);
|
||||
}
|
||||
else if (!isset($onlyFileType) || !$onlyFileType){ /*save only directories*/
|
||||
$add = true;
|
||||
}
|
||||
if (is_dir($path . Util::getSeparator() . $value)) {
|
||||
/** @var mixed $recursively */
|
||||
if (
|
||||
!is_int($recursively) && $recursively ||
|
||||
is_int($recursively) && $recursively !== 0
|
||||
) {
|
||||
$nextRecursively = is_int($recursively) ? ($recursively - 1) : $recursively;
|
||||
|
||||
$result[$value] = $this->getFileList(
|
||||
$path . Util::getSeparator() . $value,
|
||||
$nextRecursively,
|
||||
$filter,
|
||||
$onlyFileType
|
||||
);
|
||||
}
|
||||
else if (!isset($onlyFileType) || $onlyFileType) { /*save only files*/
|
||||
else if (!isset($onlyFileType) || !$onlyFileType) { /* save only directories */
|
||||
$add = true;
|
||||
}
|
||||
}
|
||||
else if (!isset($onlyFileType) || $onlyFileType) { /* save only files */
|
||||
$add = true;
|
||||
}
|
||||
|
||||
if ($add) {
|
||||
if (!empty($filter)) {
|
||||
if (preg_match('/'.$filter.'/i', $value)) {
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$result[] = $value;
|
||||
}
|
||||
if (!$add) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($filter)) {
|
||||
if (preg_match('/'.$filter.'/i', $value)) {
|
||||
$result[] = $value;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $value;
|
||||
}
|
||||
|
||||
if ($returnSingleArray) {
|
||||
@@ -677,17 +682,18 @@ class Manager
|
||||
|
||||
$pathParts = pathinfo($filePath);
|
||||
|
||||
if (!file_exists($pathParts['dirname'])) {
|
||||
/** @var string $dirname */
|
||||
$dirname = $pathParts['dirname'] ?? null;
|
||||
|
||||
if (!file_exists($dirname)) {
|
||||
$dirPermissionOriginal = $defaultPermissions['dir'];
|
||||
|
||||
$dirPermission = is_string($dirPermissionOriginal) ?
|
||||
(int) base_convert($dirPermissionOriginal, 8, 10) :
|
||||
$dirPermissionOriginal;
|
||||
|
||||
if (!$this->mkdir($pathParts['dirname'], $dirPermission)) {
|
||||
throw new PermissionError(
|
||||
'Permission denied: unable to create a folder on the server ' . $pathParts['dirname']
|
||||
);
|
||||
if (!$this->mkdir($dirname, $dirPermission)) {
|
||||
throw new PermissionError('Permission denied: unable to create a folder on the server ' . $dirname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -591,7 +591,8 @@ class Permission
|
||||
|
||||
foreach ($fileList as $fileName) {
|
||||
$pathInfo = pathinfo($fileName);
|
||||
$dirname = $pathInfo['dirname'];
|
||||
/** @var string $dirname */
|
||||
$dirname = $pathInfo['dirname'] ?? null;
|
||||
|
||||
$currentPath = $fileName;
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@ class Language
|
||||
private function getLanguageData(string $language, bool $reload = false): array
|
||||
{
|
||||
if (!$reload && isset($this->data[$language])) {
|
||||
return $this->data[$language] ?? [];
|
||||
return $this->data[$language];
|
||||
}
|
||||
|
||||
$cacheKey = $this->getCacheKey($language);
|
||||
|
||||
Reference in New Issue
Block a user