diff --git a/application/Espo/Core/AclManager.php b/application/Espo/Core/AclManager.php index df8df8823e..c7ceb48736 100644 --- a/application/Espo/Core/AclManager.php +++ b/application/Espo/Core/AclManager.php @@ -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; diff --git a/application/Espo/Core/Application.php b/application/Espo/Core/Application.php index 243844d56d..9049ddb1e0 100644 --- a/application/Espo/Core/Application.php +++ b/application/Espo/Core/Application.php @@ -31,7 +31,6 @@ namespace Espo\Core; use Espo\Core\{ ContainerBuilder, - ContainerConfiguration, InjectableFactory, Container, ApplicationUser, diff --git a/application/Espo/Core/ApplicationState.php b/application/Espo/Core/ApplicationState.php index 12720d3ccb..923f1c00a6 100644 --- a/application/Espo/Core/ApplicationState.php +++ b/application/Espo/Core/ApplicationState.php @@ -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 { diff --git a/application/Espo/Core/ContainerBuilder.php b/application/Espo/Core/ContainerBuilder.php index 6a5420473f..0477e58c91 100644 --- a/application/Espo/Core/ContainerBuilder.php +++ b/application/Espo/Core/ContainerBuilder.php @@ -122,7 +122,7 @@ class ContainerBuilder return $this; } - public function withDataCacheClassName(string $fileManagerClassName) : self + public function withDataCacheClassName(string $dataCacheClassName) : self { $this->dataCacheClassName = $dataCacheClassName; diff --git a/application/Espo/Core/ControllerManager.php b/application/Espo/Core/ControllerManager.php index 026f1c8773..ab76388eef 100644 --- a/application/Espo/Core/ControllerManager.php +++ b/application/Espo/Core/ControllerManager.php @@ -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. diff --git a/application/Espo/Core/CronManager.php b/application/Espo/Core/CronManager.php index 228065bb09..897ad297b0 100644 --- a/application/Espo/Core/CronManager.php +++ b/application/Espo/Core/CronManager.php @@ -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; diff --git a/application/Espo/Core/DataManager.php b/application/Espo/Core/DataManager.php index 8cade7c1b6..c6c1463d29 100644 --- a/application/Espo/Core/DataManager.php +++ b/application/Espo/Core/DataManager.php @@ -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()