From d82a9665c4e9a724fb79fd1ba71ecbe87a1f91f5 Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Tue, 20 Oct 2026 15:06:56 +0200 Subject: [PATCH] #311 - Deprecate DataQueueEventListener - The cleverage_process.event_listener.data_queue service is deprecated (setDeprecated(), notice when it is injected or fetched) and DataQueueEventListener is marked @deprecated: it keeps a copy of the ProcessState of every cleverage_process.data_queue event in memory, without limit. Both will be removed in v6.0. - Tests, documentation (event_dispatcher task) and CHANGELOG updated. Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 1 + config/services/event.yaml | 4 ++++ docs/reference/tasks/event_dispatcher_task.md | 5 +++++ src/EventListener/DataQueueEventListener.php | 3 +++ .../CleverAgeProcessExtensionTest.php | 14 ++++++++++++++ 5 files changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89a24625..374a2c57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Latest ------ ## Changes +* [#311](https://github.com/cleverage/process-bundle/issues/311) Deprecate the `cleverage_process.event_listener.data_queue` service and `DataQueueEventListener` (it keeps a copy of the `ProcessState` of every `cleverage_process.data_queue` event in memory, without limit): injecting or fetching the service triggers a deprecation, they will be removed in v6.0. Write your own listener of the event dispatched by the `event_dispatcher` task. Update documentation, add tests. * [#305](https://github.com/cleverage/process-bundle/issues/305) Bundle best practices, residues: the generic transformers are no longer autowired (explicit arguments). `ProcessHelpCommand` receives the `TaskRegistry` instead of the service container (passing a container is deprecated). Fetching from the service container a task of the application made public by the `TaskInterface` autoconfiguration is deprecated (`container.private` tag, new internal `PublicTaskDeprecationCompilerPass`); the tasks made public by the application itself are not concerned. Trigger the missing deprecation notices: `CheckSerializerCompilerPass`, `errors` task configuration key (use `error_outputs`). `TaskConfiguration::getErrors()` triggers a single notice on PHP 8.4+. `CleverAgeProcessBundle` is marked `@final since 5.4`. Update documentation, add tests. * [#299](https://github.com/cleverage/process-bundle/issues/299) Require `symfony/polyfill-php83`, `symfony/polyfill-php84` and `symfony/polyfill-php85`: the functions of PHP 8.3 to 8.5 can be used while supporting PHP 8.2. Rector targets PHP 8.2 (`withPhpVersion()`, `withPhpSets()` read from `composer.json`) and applies the rules using a newer function when its polyfill is required: `ProcessConfiguration` uses `array_any()` again; `array_first()` replaces `reset()` / `current()` in `ProcessConfiguration::getMainTask()`, `ConstraintLoader` and `ProcessHelpCommand` (no internal array pointer, same results). * [#279](https://github.com/cleverage/process-bundle/issues/279) Define the public API (Symfony BC promise): the classes not meant to be extended are marked `@final since 5.4` (the engine: `ProcessManager`, `ProcessConfigurationRegistry`, `TransformerRegistry`, `ContextualOptionResolver`; the models: `ProcessState`, `ProcessHistory`, `SubprocessInstance`, the configurations, the events, the `Filesystem` files; the concrete tasks and transformers), they will be `final` in v6.0: extending them triggers a deprecation with the Symfony `DebugClassLoader`. The abstract classes, interfaces, traits, exceptions and the file tasks extended by other tasks (`FileReaderTask`, `LineReaderTask`, `FolderBrowserTask`, `CsvReaderTask`, `InputCsvReaderTask`, `Filesystem\CsvResource`) stay open. `TaskRegistry`, new in this version, is `final`. The infrastructure classes are marked `@internal`: `CleverAgeProcessExtension`, `Configuration`, the commands, `DataQueueEventListener`, `PhpFunctionProvider`, the Monolog processors, `ProcessLogger` and `TaskLogger`. Update documentation. diff --git a/config/services/event.yaml b/config/services/event.yaml index 8bb1ae18..b0477581 100644 --- a/config/services/event.yaml +++ b/config/services/event.yaml @@ -2,5 +2,9 @@ services: cleverage_process.event_listener.data_queue: class: CleverAge\ProcessBundle\EventListener\DataQueueEventListener public: false + deprecated: + package: cleverage/process-bundle + version: '5.4' + message: 'The "%service_id%" service is deprecated, it will be removed in v6.0: write your own listener of the event dispatched by the event_dispatcher task.' tags: - { name: kernel.event_listener, event: cleverage_process.data_queue, method: pushData } diff --git a/docs/reference/tasks/event_dispatcher_task.md b/docs/reference/tasks/event_dispatcher_task.md index 3f1b8be9..89d1acb3 100644 --- a/docs/reference/tasks/event_dispatcher_task.md +++ b/docs/reference/tasks/event_dispatcher_task.md @@ -67,6 +67,11 @@ public function onDataQueue(EventDispatcherTaskEvent $event): void `CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent`. Every `EventDispatcherTask` without `event_name` then triggers the same listeners. +**Deprecated since 5.4, removed in v6.0**: the bundle listens to the `cleverage_process.data_queue` event with the +`cleverage_process.event_listener.data_queue` service (`DataQueueEventListener`), which keeps a copy of the +`ProcessState` of every event in memory. Injecting or fetching this service triggers an `E_USER_DEPRECATED` error: write +your own listener, as above. + **Deprecated since v5, removed in v6.0**: from v4.0 to v5.0, the `event_name` option was ignored and the event was always dispatched under its class name. To preserve backward compatibility, when `event_name` is set (and differs from the event class name) and listeners subscribe to `CleverAge\ProcessBundle\Event\EventDispatcherTaskEvent`, the event is also diff --git a/src/EventListener/DataQueueEventListener.php b/src/EventListener/DataQueueEventListener.php index d5f1bb89..9c54d756 100644 --- a/src/EventListener/DataQueueEventListener.php +++ b/src/EventListener/DataQueueEventListener.php @@ -22,6 +22,9 @@ * Used mostly for testing purpose. * * @internal + * + * @deprecated since cleverage/process-bundle 5.4, will be removed in 6.0: write your own listener of the event + * dispatched by the event_dispatcher task */ class DataQueueEventListener { diff --git a/tests/DependencyInjection/CleverAgeProcessExtensionTest.php b/tests/DependencyInjection/CleverAgeProcessExtensionTest.php index a0f5d545..ddf56962 100644 --- a/tests/DependencyInjection/CleverAgeProcessExtensionTest.php +++ b/tests/DependencyInjection/CleverAgeProcessExtensionTest.php @@ -191,4 +191,18 @@ public function testTheProcessManagerIsResetBetweenExecutions(): void $container->getDefinition('cleverage_process.manager.process')->getTag('kernel.reset') ); } + + public function testTheDataQueueListenerIsDeprecated(): void + { + $container = new ContainerBuilder(); + (new CleverAgeProcessExtension())->load([], $container); + + $id = 'cleverage_process.event_listener.data_queue'; + $definition = $container->getDefinition($id); + self::assertTrue($definition->isDeprecated()); + $deprecation = $definition->getDeprecation($id); + self::assertSame('cleverage/process-bundle', $deprecation['package']); + self::assertSame('5.4', $deprecation['version']); + self::assertStringStartsWith(\sprintf('The "%s" service is deprecated, it will be removed in v6.0', $id), $deprecation['message']); + } }