From 500c57b9fe3dadce8667db6731262dfb4a7337db Mon Sep 17 00:00:00 2001 From: Kai Eichinger Date: Thu, 30 Jul 2026 12:56:45 +0200 Subject: [PATCH 1/6] Display name of wrapped Task class when running `sf debug:scheduler` (cherry picked from commit 00a589b410dd965ef5f53985574804f996655871) --- CHANGELOG.md | 6 ++++++ src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b250a8e..9c9f07a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,12 @@ * (improvement) Log a critical error instead of failing, if a task can't be identified during a run. +3.4.2 +===== + +* (impprovement) Display class name of wrapped Task when running `sf debug:scheduler` + + 3.4.1 ===== diff --git a/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php b/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php index 733cae9..718cf5e 100644 --- a/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php +++ b/src/Task/DispatchAfterRunTask/DispatchAfterRunTask.php @@ -15,7 +15,7 @@ * redispatches the given task. */ #[AsMessage(transport: TransportsHelper::INTERNAL_TRANSPORT_NAME)] -readonly class DispatchAfterRunTask extends Task implements TaskManagerInternalTask +readonly class DispatchAfterRunTask extends Task implements TaskManagerInternalTask, \Stringable { public function __construct ( public object $task, @@ -36,4 +36,10 @@ public function getMetaData () : TaskMetaData \sprintf("Redispatch task '%s' after the current run", $label), ); } + + #[\Override] + public function __toString () : string + { + return $this->task::class; + } } From 5cc1fa5f6bd2aa1426d59d769e44cde0849a316a Mon Sep 17 00:00:00 2001 From: Kai Eichinger Date: Mon, 21 Sep 2026 16:55:57 +0200 Subject: [PATCH 2/6] =?UTF-8?q?Add=20proper=20support=20for=20fetching=20a?= =?UTF-8?q?nd=20validating=20Tasks=20that=20are=20configured=20via=20`#[As?= =?UTF-8?q?Message(=E2=80=A6)]`=20attribute.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit c8d05cb5405b1ac19803a8c83cd717669eeeccac) --- CHANGELOG.md | 1 + .../FindTaskClassesCompilerPass.php | 22 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c9f07a..1fae0d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ ===== * (impprovement) Display class name of wrapped Task when running `sf debug:scheduler` +* (bug) Add proper support for fetching and validating Tasks that are configured via `#[AsMessage(…)]` attribute. 3.4.1 diff --git a/src/DependencyInjection/FindTaskClassesCompilerPass.php b/src/DependencyInjection/FindTaskClassesCompilerPass.php index 970d2c0..b24f0e9 100644 --- a/src/DependencyInjection/FindTaskClassesCompilerPass.php +++ b/src/DependencyInjection/FindTaskClassesCompilerPass.php @@ -5,6 +5,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Torr\TaskManager\Config\BundleConfig; +use Torr\TaskManager\Task\Task; /** * Compiler pass, that collects all tasks from the container that are from the app @@ -22,20 +23,27 @@ public function process (ContainerBuilder $container) : void { $taskClasses = []; - foreach ($container->findTaggedServiceIds("task-manager.task") as $taskServiceId => $config) + foreach ($container->getDefinitions() as $definition) { - $definition = $container->getDefinition($taskServiceId); $taskFQCN = $definition->getClass(); if (null !== $taskFQCN && str_starts_with($taskFQCN, "App\\")) { + $reflection = $container->getReflectionClass($taskFQCN, false); + + if (null === $reflection || !$reflection->isSubclassOf(Task::class)) + { + continue; + } + $taskClasses[] = $taskFQCN; - } - // Remove task service definition, as these must never be a service - // in the actual runtime. We just use the mechanism to collect all - // tasks in the app. - $container->removeDefinition($taskServiceId); + // Ensure that our Task classes are removed from the container definitions. Depending on the way + // the Tasks are registered (either via `AsMessage` attribute or via `messenger.yaml` config), + // they'll be excluded automatically. This happens automatically when the `AsMessage` attribute is being used. + // Here we're making sure that this also happens when using the YAML config file. + $definition->addTag("container.excluded"); + } } $container->getDefinition(BundleConfig::class) From 5fbd826a5213a2b722c90dfd087c577014bfe4bd Mon Sep 17 00:00:00 2001 From: Kai Eichinger Date: Mon, 21 Sep 2026 17:01:05 +0200 Subject: [PATCH 3/6] Reduce nesting (cherry picked from commit 5ebd7eda003a789299035e3e69498cb47d952c17) --- .../FindTaskClassesCompilerPass.php | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/DependencyInjection/FindTaskClassesCompilerPass.php b/src/DependencyInjection/FindTaskClassesCompilerPass.php index b24f0e9..1278ae3 100644 --- a/src/DependencyInjection/FindTaskClassesCompilerPass.php +++ b/src/DependencyInjection/FindTaskClassesCompilerPass.php @@ -23,27 +23,29 @@ public function process (ContainerBuilder $container) : void { $taskClasses = []; - foreach ($container->getDefinitions() as $definition) + foreach ($container->getDefinitions() as $taskServiceId => $definition) { $taskFQCN = $definition->getClass(); - if (null !== $taskFQCN && str_starts_with($taskFQCN, "App\\")) + if (null === $taskFQCN || !str_starts_with($taskFQCN, "App\\")) { - $reflection = $container->getReflectionClass($taskFQCN, false); - - if (null === $reflection || !$reflection->isSubclassOf(Task::class)) - { - continue; - } + continue; + } - $taskClasses[] = $taskFQCN; + $reflection = $container->getReflectionClass($taskFQCN, false); - // Ensure that our Task classes are removed from the container definitions. Depending on the way - // the Tasks are registered (either via `AsMessage` attribute or via `messenger.yaml` config), - // they'll be excluded automatically. This happens automatically when the `AsMessage` attribute is being used. - // Here we're making sure that this also happens when using the YAML config file. - $definition->addTag("container.excluded"); + if (null === $reflection || !$reflection->isSubclassOf(Task::class)) + { + continue; } + + $taskClasses[] = $taskFQCN; + + // Ensure that our Task classes are removed from the container definitions. Depending on the way + // the Tasks are registered (either via `AsMessage` attribute or via `messenger.yaml` config), + // they'll be excluded automatically. This happens automatically when the `AsMessage` attribute is being used. + // Here we're making sure that this also happens when using the YAML config file. + $definition->addTag("container.excluded"); } $container->getDefinition(BundleConfig::class) From 077fac1bf0113416c1aa70c897528aa4144df1e5 Mon Sep 17 00:00:00 2001 From: Kai Eichinger Date: Mon, 21 Sep 2026 17:02:14 +0200 Subject: [PATCH 4/6] Remove auto-tag `task-manager.task` This tag was previously only used for fetching Tasks during ContainerBuild, which has now been replaced by a different method that works better for Tasks that have been registered either via `#[AsMessage]` or `messenger.yaml` config (cherry picked from commit 0c554a37778101333f55e895a21e2637867aa938) --- src/TaskManagerBundle.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/TaskManagerBundle.php b/src/TaskManagerBundle.php index 190d4d9..b8f8910 100644 --- a/src/TaskManagerBundle.php +++ b/src/TaskManagerBundle.php @@ -8,7 +8,6 @@ use Torr\TaskManager\DependencyInjection\AutoDetectFailureTransportsCompilerPass; use Torr\TaskManager\DependencyInjection\FindTaskClassesCompilerPass; use Torr\TaskManager\DependencyInjection\TaskManagerBundleExtension; -use Torr\TaskManager\Task\Task; final class TaskManagerBundle extends Bundle { @@ -28,9 +27,6 @@ public function build (ContainerBuilder $container) : void $container ->addCompilerPass(new AutoDetectFailureTransportsCompilerPass()) ->addCompilerPass(new FindTaskClassesCompilerPass()); - - $container->registerForAutoconfiguration(Task::class) - ->addTag("task-manager.task"); } /** From d42c7acfa63a83fd76f3746c4c0ecec723c37880 Mon Sep 17 00:00:00 2001 From: Kai Eichinger Date: Mon, 21 Sep 2026 17:04:06 +0200 Subject: [PATCH 5/6] Add changelog entry (cherry picked from commit bdc2a319aa60558a77421c6b7bad7ddc2cee1302) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fae0d8..4e66edc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * (impprovement) Display class name of wrapped Task when running `sf debug:scheduler` * (bug) Add proper support for fetching and validating Tasks that are configured via `#[AsMessage(…)]` attribute. +* (internal) Remove previously used Tag `task-manager.task`. 3.4.1 From 6e6d72514e3bddf680fd9a08a1a942c3f59c2646 Mon Sep 17 00:00:00 2001 From: Kai Eichinger Date: Mon, 21 Sep 2026 17:05:19 +0200 Subject: [PATCH 6/6] Fix deprecation in `TaskLog`'s `OrderBy` configuration (cherry picked from commit 6f2e4dfc456798fc39d667d141542dbf6f630460) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e66edc..3ac8ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * (impprovement) Display class name of wrapped Task when running `sf debug:scheduler` * (bug) Add proper support for fetching and validating Tasks that are configured via `#[AsMessage(…)]` attribute. * (internal) Remove previously used Tag `task-manager.task`. +* (improvement) Fix deprecation in `TaskLog`'s `OrderBy` configuration. 3.4.1