mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
cs
This commit is contained in:
@@ -52,7 +52,7 @@ class JobFactory
|
||||
$className = $this->getClassName($name);
|
||||
|
||||
if (!$className) {
|
||||
throw new Error("Job '{$name}' not found.");
|
||||
throw new Error("Job '$name' not found.");
|
||||
}
|
||||
|
||||
return $this->createByClassName($className);
|
||||
@@ -66,9 +66,7 @@ class JobFactory
|
||||
*/
|
||||
public function createByClassName(string $className): object
|
||||
{
|
||||
$job = $this->injectableFactory->create($className);
|
||||
|
||||
return $job;
|
||||
return $this->injectableFactory->create($className);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
namespace Espo\Core\Job;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Job\QueueProcessor\Params;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Log;
|
||||
|
||||
@@ -91,11 +91,11 @@ class JobRunner
|
||||
$jobEntity = $this->entityManager->getEntityById(JobEntity::ENTITY_TYPE, $id);
|
||||
|
||||
if (!$jobEntity) {
|
||||
throw new RuntimeException("Job '{$id}' not found.");
|
||||
throw new RuntimeException("Job '$id' not found.");
|
||||
}
|
||||
|
||||
if ($jobEntity->getStatus() !== Status::READY) {
|
||||
throw new RuntimeException("Can't run job '{$id}' with not Ready status.");
|
||||
throw new RuntimeException("Can't run job '$id' with not Ready status.");
|
||||
}
|
||||
|
||||
$this->setJobRunning($jobEntity);
|
||||
@@ -131,7 +131,7 @@ class JobRunner
|
||||
else {
|
||||
$id = $jobEntity->getId();
|
||||
|
||||
throw new Error("Not runnable job '{$id}'.");
|
||||
throw new Error("Not runnable job '$id'.");
|
||||
}
|
||||
}
|
||||
catch (Throwable $e) {
|
||||
@@ -139,7 +139,7 @@ class JobRunner
|
||||
|
||||
$jobId = $jobEntity->hasId() ? $jobEntity->getId() : null;
|
||||
|
||||
$msg = "JobManager: Failed job running, job '{$jobId}'. " .
|
||||
$msg = "JobManager: Failed job running, job '$jobId'. " .
|
||||
$e->getMessage() . "; at " . $e->getFile() . ":" . $e->getLine() . ".";
|
||||
|
||||
if ($this->config->get('logger.printTrace')) {
|
||||
@@ -266,7 +266,7 @@ class JobRunner
|
||||
}
|
||||
|
||||
if (!method_exists($service, $methodName)) {
|
||||
throw new Error("No method '{$methodName}' in service '{$serviceName}'.");
|
||||
throw new Error("No method '$methodName' in service '$serviceName'.");
|
||||
}
|
||||
|
||||
$service->$methodName(
|
||||
|
||||
@@ -65,7 +65,7 @@ class JobScheduler
|
||||
public function setClassName(string $className): self
|
||||
{
|
||||
if (!class_exists($className)) {
|
||||
throw new RuntimeException("Class '{$className}' does not exist.");
|
||||
throw new RuntimeException("Class '$className' does not exist.");
|
||||
}
|
||||
|
||||
$class = new ReflectionClass($className);
|
||||
@@ -74,7 +74,7 @@ class JobScheduler
|
||||
!$class->implementsInterface(Job::class) &&
|
||||
!$class->implementsInterface(JobDataLess::class)
|
||||
) {
|
||||
throw new RuntimeException("Class '{$className}' does not implement 'Job' or 'JobDataLess' interface.");
|
||||
throw new RuntimeException("Class '$className' does not implement 'Job' or 'JobDataLess' interface.");
|
||||
}
|
||||
|
||||
$this->className = $className;
|
||||
@@ -115,6 +115,7 @@ class JobScheduler
|
||||
$timeCopy = $time;
|
||||
|
||||
if (!is_null($time) && !$time instanceof DateTimeImmutable) {
|
||||
/** @noinspection PhpParamsInspection */
|
||||
$timeCopy = DateTimeImmutable::createFromMutable($time);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class JobTask extends AsyncTask
|
||||
catch (Throwable $e) {
|
||||
$log = $app->getContainer()->getByClass(Log::class);
|
||||
|
||||
$log->error("JobTask: Failed to run job '{$this->jobId}'. Error: " . $e->getMessage());
|
||||
$log->error("JobTask: Failed to run job '$this->jobId'. Error: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class PreparatorFactory
|
||||
$className = $this->metadataProvider->getPreparatorClassName($name);
|
||||
|
||||
if (!$className) {
|
||||
throw new RuntimeException("Preparator for job '{$name}' not found.");
|
||||
throw new RuntimeException("Preparator for job '$name' not found.");
|
||||
}
|
||||
|
||||
return $this->injectableFactory->create($className);
|
||||
|
||||
@@ -81,7 +81,7 @@ class ScheduleProcessor
|
||||
catch (Throwable $e) {
|
||||
$id = $scheduledJob->getId();
|
||||
|
||||
$this->log->error("Scheduled Job '{$id}': " . $e->getMessage());
|
||||
$this->log->error("Scheduled Job '$id': " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class ScheduleProcessor
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->log->error(
|
||||
"Scheduled Job '{$id}': Scheduling expression error: " .
|
||||
"Scheduled Job '$id': Scheduling expression error: " .
|
||||
$e->getMessage() . '.');
|
||||
|
||||
return null;
|
||||
@@ -176,7 +176,7 @@ class ScheduleProcessor
|
||||
return $cronExpression->getNextRunDate()->format(DateTimeUtil::SYSTEM_DATE_TIME_FORMAT);
|
||||
}
|
||||
catch (Exception) {
|
||||
$this->log->error("Scheduled Job '{$id}': Unsupported scheduling expression '{$scheduling}'.");
|
||||
$this->log->error("Scheduled Job '$id': Unsupported scheduling expression '$scheduling'.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user