This commit is contained in:
Yuri Kuznetsov
2020-12-31 15:12:44 +02:00
parent 52904999fb
commit ec40acfac1
7 changed files with 32 additions and 34 deletions
+3 -2
View File
@@ -43,7 +43,6 @@ use Espo\Core\{
Acl\GlobalRestricton,
Acl as UserAclWrapper,
Acl\Table as AclTable,
Utils\Util,
};
use StdClass;
@@ -409,7 +408,9 @@ class AclManager
$userId = $target;
}
if ($user->id === $userId) return true;
if ($user->id === $userId) {
return true;
}
if ($permission === 'no') {
return false;
-1
View File
@@ -31,7 +31,6 @@ namespace Espo\Core;
use Espo\Core\{
ContainerBuilder,
ContainerConfiguration,
InjectableFactory,
Container,
ApplicationUser,
+3 -3
View File
@@ -55,7 +55,7 @@ class ApplicationState
}
/**
* Get a portal ID (if an applicaition is portal).
* Get a portal ID (if an application is portal).
*/
public function getPortalId() : string
{
@@ -67,7 +67,7 @@ class ApplicationState
}
/**
* Get a portal entity (if an applicaition is portal).
* Get a portal entity (if an application is portal).
*/
public function getPortal() : PortalEntity
{
@@ -136,7 +136,7 @@ class ApplicationState
/**
* Whether logged as an api user.
* Whether logged as an API user.
*/
public function isApi() : bool
{
+1 -1
View File
@@ -122,7 +122,7 @@ class ContainerBuilder
return $this;
}
public function withDataCacheClassName(string $fileManagerClassName) : self
public function withDataCacheClassName(string $dataCacheClassName) : self
{
$this->dataCacheClassName = $dataCacheClassName;
@@ -32,15 +32,12 @@ namespace Espo\Core;
use Espo\Core\{
InjectableFactory,
Utils\ClassFinder,
Utils\Util,
Api\Request,
Api\Response,
Exceptions\NotFound,
Exceptions\BadRequest,
};
use ReflectionClass;
use StdClass;
/**
* Creates controller instances and processes actions.
+17 -13
View File
@@ -29,14 +29,12 @@
namespace Espo\Core;
use PDO;
use Espo\Core\{
Exceptions\Error,
ServiceFactory,
InjectableFactory,
Utils\Config,
Utils\File\Manager as FileManager,
Utils\Json,
Utils\System,
Utils\ScheduledJob,
Utils\Cron\ScheduledJob as CronScheduledJob,
@@ -51,9 +49,6 @@ use Spatie\Async\Pool as AsyncPool;
use Cron\CronExpression;
use Espo\Core\Exceptions\NotFound;
use Espo\Core\Exceptions\Error;
use Exception;
use Throwable;
@@ -187,6 +182,7 @@ class CronManager
{
if (!$this->checkLastRunTime()) {
$GLOBALS['log']->info('CronManager: Stop cron running, too frequent execution.');
return;
}
@@ -297,6 +293,7 @@ class CronManager
if ($useProcessPool) {
$task = new JobTask($job->id);
$pool->add($task);
return;
@@ -310,11 +307,15 @@ class CronManager
*/
public function runJobById(string $id)
{
if (empty($id)) throw new Error();
if (empty($id)) {
throw new Error();
}
$job = $this->entityManager->getEntity('Job', $id);
if (!$job) throw new Error("Job {$id} not found.");
if (!$job) {
throw new Error("Job {$id} not found.");
}
if ($job->get('status') !== self::READY) {
throw new Error("Can't run job {$id} with no status Ready.");
@@ -377,7 +378,10 @@ class CronManager
);
}
if ($isSuccess) return true;
if ($isSuccess) {
return true;
}
return false;
}
@@ -426,7 +430,6 @@ class CronManager
$service = $this->serviceFactory->create($serviceName);
$methodNameDeprecated = $job->get('method');
$methodName = $job->get('methodName');
if (!$methodName) {
@@ -468,7 +471,6 @@ class CronManager
$activeScheduledJobList = $this->getCronScheduledJobUtil()->getActiveScheduledJobList();
$runningScheduledJobIdList = $this->getCronJobUtil()->getRunningScheduledJobIdList();
$createdJobIdList = [];
foreach ($activeScheduledJobList as $scheduledJob) {
$scheduling = $scheduledJob->get('scheduling');
$asSoonAsPossible = in_array($scheduling, $this->asSoonAsPossibleSchedulingList);
@@ -482,7 +484,8 @@ class CronManager
}
catch (Exception $e) {
$GLOBALS['log']->error(
'CronManager (ScheduledJob ['.$scheduledJob->id.']): Scheduling string error - '. $e->getMessage() . '.'
'CronManager (ScheduledJob ' . $scheduledJob->id . '): Scheduling string error - ' .
$e->getMessage() . '.'
);
continue;
@@ -493,7 +496,8 @@ class CronManager
}
catch (Exception $e) {
$GLOBALS['log']->error(
'CronManager (ScheduledJob ['.$scheduledJob->id.']): Unsupported CRON expression ['.$scheduling.']'
'CronManager (ScheduledJob '. $scheduledJob->id . '): ' .
'Unsupported CRON expression ' . $scheduling . '.'
);
continue;
+8 -11
View File
@@ -211,7 +211,7 @@ class DataManager
$job = $entityManager
->getRepository('ScheduledJob')
->where([
'job' => $jobName
'job' => $jobName,
])
->findOne();
@@ -289,14 +289,15 @@ class DataManager
$sql = "SHOW VARIABLES LIKE 'ft_min_word_len'";
$sth = $pdo->prepare($sql);
$sth->execute();
$fullTextSearchMinLength = null;
if ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
if (isset($row['Value'])) {
$fullTextSearchMinLength = intval($row['Value']);
}
$row = $sth->fetch(PDO::FETCH_ASSOC);
if ($row && isset($row['Value'])) {
$fullTextSearchMinLength = intval($row['Value']);
}
$config->set('fullTextSearchMinLength', $fullTextSearchMinLength);
@@ -304,17 +305,13 @@ class DataManager
protected function setCryptKeyConfigParameter()
{
$config = $this->config;
$cryptKey = $config->get('cryptKey');
if ($cryptKey) {
if ($this->config->get('cryptKey')) {
return;
}
$cryptKey = Util::generateSecretKey();
$config->set('cryptKey', $cryptKey);
$this->config->set('cryptKey', $cryptKey);
}
protected function disableHooks()