diff --git a/Classes/Job/Aspect/DeferMethodCallAspect.php b/Classes/Job/Aspect/DeferMethodCallAspect.php index 731920f..763c0b5 100644 --- a/Classes/Job/Aspect/DeferMethodCallAspect.php +++ b/Classes/Job/Aspect/DeferMethodCallAspect.php @@ -39,9 +39,9 @@ class DeferMethodCallAspect protected $reflectionService; /** - * @var boolean + * @var string */ - protected $processingJob = false; + protected string $processingMethodCallHash = ''; /** * @param JoinPointInterface $joinPoint The current join point @@ -50,7 +50,7 @@ class DeferMethodCallAspect */ public function queueMethodCallAsJob(JoinPointInterface $joinPoint) { - if ($this->processingJob) { + if ($this->processingMethodCallHash === StaticMethodCallJob::methodCallHash($joinPoint->getClassName(), $joinPoint->getMethodName())) { return $joinPoint->getAdviceChain()->proceed($joinPoint); } /** @var Defer $deferAnnotation */ @@ -62,10 +62,10 @@ public function queueMethodCallAsJob(JoinPointInterface $joinPoint) } /** - * @param boolean $processingJob + * @param string $processingMethodCallHash */ - public function setProcessingJob($processingJob) + public function setProcessingMethodCallHash(string $processingMethodCallHash): void { - $this->processingJob = $processingJob; + $this->processingMethodCallHash = $processingMethodCallHash; } } diff --git a/Classes/Job/StaticMethodCallJob.php b/Classes/Job/StaticMethodCallJob.php index 7144195..060bef2 100644 --- a/Classes/Job/StaticMethodCallJob.php +++ b/Classes/Job/StaticMethodCallJob.php @@ -75,7 +75,7 @@ public function __construct($className, $methodName, array $arguments) public function execute(QueueInterface $queue, Message $message): bool { $service = $this->objectManager->get($this->className); - $this->deferMethodCallAspect->setProcessingJob(true); + $this->deferMethodCallAspect->setProcessingMethodCallHash(static::methodCallHash($this->className, $this->methodName)); try { $methodName = $this->methodName; call_user_func_array([$service, $methodName], $this->arguments); @@ -83,7 +83,7 @@ public function execute(QueueInterface $queue, Message $message): bool } catch (\Exception $exception) { throw $exception; } finally { - $this->deferMethodCallAspect->setProcessingJob(false); + $this->deferMethodCallAspect->setProcessingMethodCallHash(''); } } @@ -95,4 +95,9 @@ public function getLabel(): string $arguments = array_map([VariableDumper::class, 'dumpValue'], $this->arguments); return sprintf('%s::%s(%s)', $this->className, $this->methodName, implode(', ', $arguments)); } + + public static function methodCallHash($className, $methodName): string + { + return md5($className . '::' . $methodName); + } }