From d05474e60db00008fbfb596790eeac301458e2ec Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Thu, 22 Oct 2026 18:50:19 +0200 Subject: [PATCH 1/2] #216 - Cookbooks with task codes, application `upload_directory` parameter left alone, deprecation notice for the unused `$translator` argument, scheduler log levels Co-Authored-By: Claude Opus 5.5 (1M context) --- CHANGELOG.md | 3 ++ UPGRADE.md | 8 ++++ config/services/controller.yaml | 1 - docs/cookbooks/form_file_upload.md | 6 +-- docs/cookbooks/http_api_launch.md | 6 +-- docs/cookbooks/scheduled_process.md | 6 +-- docs/reference/01-bundle_configuration.md | 2 +- docs/reference/05-scheduler.md | 2 +- .../Admin/ProcessExecutionCrudController.php | 15 ++++--- .../Compiler/UploadDirectoryParameterPass.php | 11 +++-- .../ProcessExecutionCrudControllerTest.php | 45 +++++++++++++++++++ .../UploadDirectoryParameterPassTest.php | 22 ++++++--- 12 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 tests/Controller/Admin/ProcessExecutionCrudControllerTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 614eb77..1b251f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ Latest ------ +### Changes +* [#216](https://github.com/cleverage/ui-process-bundle/issues/216) Cookbooks with task codes, application `upload_directory` parameter left alone, deprecation notice for the unused `$translator` argument, scheduler log levels. + ## Changes * [#186](https://github.com/cleverage/ui-process-bundle/issues/186) `ProcessExecuteController`, `ProcessExecuteHandler`, `LaunchType`, `ProcessConfigurationsManager` and `IsValidProcessCodeValidator` are typed on `ProcessManagerInterface` / `ProcessConfigurationRegistryInterface` (process-bundle 5.4) instead of the concrete classes, `@final since 5.4`: the process manager and the process configuration registry can be decorated or replaced for the UI. diff --git a/UPGRADE.md b/UPGRADE.md index 81eae1b..fd37c27 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,6 +1,14 @@ Upgrade Guide ============= +## Latest + +### Process executions controller + +The `$translator` argument of `ProcessExecutionCrudController::__construct()` is deprecated (it is not used since 3.3, +the duration format being defined in the `admin/field/duration.html.twig` template): passing it triggers a deprecation, +it will be removed in 4.0. Only an application that redefines this controller service is concerned. + ## v3.3 ### Route names diff --git a/config/services/controller.yaml b/config/services/controller.yaml index 97c4806..b7dd57b 100644 --- a/config/services/controller.yaml +++ b/config/services/controller.yaml @@ -62,7 +62,6 @@ services: arguments: $processExecutionRepository: '@cleverage_ui_process.repository.process_execution' $logDirectory: '%kernel.logs_dir%' - $translator: '@translator' # $staleAfter: set by the extension (process_execution.stale_after) calls: - [setContainer, ['@Psr\Container\ContainerInterface']] diff --git a/docs/cookbooks/form_file_upload.md b/docs/cookbooks/form_file_upload.md index a93ec3b..3b857b4 100644 --- a/docs/cookbooks/form_file_upload.md +++ b/docs/cookbooks/form_file_upload.md @@ -38,7 +38,7 @@ clever_age_process: message: 'delimiter context must be , or ;. {{ value }} given.' tasks: log_file: - service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask' + task: logger options: level: info message: 'Read file' @@ -46,13 +46,13 @@ clever_age_process: outputs: [read] read: - service: '@CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask' + task: input_csv_reader options: delimiter: '{{ delimiter }}' # Contextualized option, set from the launch form outputs: [log_line] log_line: - service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask' + task: logger options: level: info message: 'Read line' diff --git a/docs/cookbooks/http_api_launch.md b/docs/cookbooks/http_api_launch.md index 0d16d96..fe1ce55 100644 --- a/docs/cookbooks/http_api_launch.md +++ b/docs/cookbooks/http_api_launch.md @@ -18,7 +18,7 @@ clever_age_process: target: Logs tasks: request: - service: '@CleverAge\RestProcessBundle\Task\RequestTask' + task: rest_request options: client: apicarto_ign url: '/codes-postaux/communes/{codePostal}' @@ -27,14 +27,14 @@ clever_age_process: outputs: [decode] decode: - service: '@CleverAge\ProcessBundle\Task\TransformerTask' + task: transformer options: transformers: json_decode: ~ # Generic transformer defined in the application outputs: [log] log: - service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask' + task: logger options: level: info message: 'Communes fetched' diff --git a/docs/cookbooks/scheduled_process.md b/docs/cookbooks/scheduled_process.md index 7579182..3b25607 100644 --- a/docs/cookbooks/scheduled_process.md +++ b/docs/cookbooks/scheduled_process.md @@ -22,7 +22,7 @@ clever_age_process: value: King tasks: read: - service: '@CleverAge\DoctrineProcessBundle\Task\EntityManager\DoctrineReaderTask' + task: doctrine_reader options: class_name: 'App\Entity\Author' criteria: @@ -30,13 +30,13 @@ clever_age_process: outputs: [log, remove] log: - service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask' + task: logger options: level: warning # Counted in the execution report message: 'Removing author' remove: - service: '@CleverAge\DoctrineProcessBundle\Task\EntityManager\DoctrineRemoverTask' + task: doctrine_remover ``` Then, in the UI, open "Process > Scheduler" and create a schedule: diff --git a/docs/reference/01-bundle_configuration.md b/docs/reference/01-bundle_configuration.md index 754caf8..acb371a 100644 --- a/docs/reference/01-bundle_configuration.md +++ b/docs/reference/01-bundle_configuration.md @@ -97,7 +97,7 @@ Container parameters | Parameter | Default | Description | |-----------------------------------------|-------------------------------------------|-------------| | `cleverage_ui_process.upload_directory` | `%kernel.project_dir%/var/storage/uploads` | Directory where files uploaded from the launch form or the [HTTP API](06-http_api.md) are stored before being passed as process input. | -| `upload_directory` | `%cleverage_ui_process.upload_directory%` | Deprecated since 3.3, removed in 4.0: use `cleverage_ui_process.upload_directory`. When your application still sets it, its value is used (unless `cleverage_ui_process.upload_directory` is also set), with a deprecation. | +| `upload_directory` | `%cleverage_ui_process.upload_directory%` | Deprecated since 3.3, removed in 4.0: use `cleverage_ui_process.upload_directory`. When your application still sets it, its value is used, with a deprecation. If your application has its own `upload_directory` parameter (e.g. for another bundle), also set `cleverage_ui_process.upload_directory`: the bundle then leaves `upload_directory` alone, without deprecation. | It can be overridden in your application: diff --git a/docs/reference/05-scheduler.md b/docs/reference/05-scheduler.md index a2481e7..aa419e6 100644 --- a/docs/reference/05-scheduler.md +++ b/docs/reference/05-scheduler.md @@ -25,7 +25,7 @@ How it works - The bundle registers a schedule provider named `cron` (`CleverAge\UiProcessBundle\Scheduler\CronScheduler`), so Symfony creates the `scheduler_cron` transport. It builds a recurring message for each valid and enabled - `ProcessSchedule`. Invalid schedules are skipped and logged (`info` level, `scheduler` channel). + `ProcessSchedule`. Invalid schedules are skipped and logged (`info` level, `scheduler` channel); a schedule that cannot be added (e.g. a duplicate, an expression refused by the Scheduler component) is logged at the `critical` level. - When a schedule is due, the `scheduler_cron` worker receives a `CronProcessMessage`. It reads the schedule again from the database: if it has been disabled or deleted since, the process is not run (logged, `info` level, `scheduler` channel). Otherwise, it dispatches a `ProcessExecuteMessage` (with the current schedule input and diff --git a/src/Controller/Admin/ProcessExecutionCrudController.php b/src/Controller/Admin/ProcessExecutionCrudController.php index 1cabe83..a394c83 100644 --- a/src/Controller/Admin/ProcessExecutionCrudController.php +++ b/src/Controller/Admin/ProcessExecutionCrudController.php @@ -46,17 +46,20 @@ class ProcessExecutionCrudController extends AbstractCrudController { /** - * @param TranslatorInterface $translator deprecated, no longer used (the duration format is defined in the - * admin/field/duration.html.twig template), will be removed in 4.0 - * @param int $staleAfter seconds without heartbeat after which a started execution is considered - * as not responding + * @param TranslatorInterface|null $translator deprecated since 3.4, no longer used (the duration format is defined in + * the admin/field/duration.html.twig template), will be removed in 4.0 + * @param int $staleAfter seconds without heartbeat after which a started execution is + * considered as not responding */ - public function __construct(// @phpstan-ignore constructor.unusedParameter ($translator deprecated, kept for BC) + public function __construct( private readonly ProcessExecutionRepository $processExecutionRepository, private readonly string $logDirectory, - TranslatorInterface $translator, + ?TranslatorInterface $translator = null, private readonly int $staleAfter = 900, ) { + if ($translator instanceof TranslatorInterface) { + trigger_deprecation('cleverage/ui-process-bundle', '3.4', 'Passing a translator to "%s::__construct()" is deprecated, it is not used. The argument will be removed in 4.0.', self::class); + } } public static function getEntityFqcn(): string diff --git a/src/DependencyInjection/Compiler/UploadDirectoryParameterPass.php b/src/DependencyInjection/Compiler/UploadDirectoryParameterPass.php index 406b8e7..ae6d183 100644 --- a/src/DependencyInjection/Compiler/UploadDirectoryParameterPass.php +++ b/src/DependencyInjection/Compiler/UploadDirectoryParameterPass.php @@ -18,8 +18,9 @@ /** * The "upload_directory" parameter is deprecated since 3.3 for "cleverage_ui_process.upload_directory": when the - * application still overrides it, its value is used (unless the new parameter is also set), with a deprecation. - * Reading it is deprecated too. + * application still overrides it, its value is used, with a deprecation. Reading it is deprecated too. When the + * application also sets "cleverage_ui_process.upload_directory", its "upload_directory" parameter is its own (e.g. for + * another bundle): it is left alone, without deprecation. * * @internal */ @@ -40,9 +41,13 @@ public function process(ContainerBuilder $container): void } $value = $parameters[self::DEPRECATED_PARAMETER]; + if (self::DEPRECATED_DEFAULT_VALUE !== $value && self::DEFAULT_VALUE !== ($parameters[self::PARAMETER] ?? null)) { + // Both parameters are set: "upload_directory" is a parameter of the application, unrelated to the bundle + return; + } if (self::DEPRECATED_DEFAULT_VALUE !== $value) { trigger_deprecation('cleverage/ui-process-bundle', '3.3', 'Setting the "%s" parameter is deprecated, set "%s" instead. It will be ignored in 4.0.', self::DEPRECATED_PARAMETER, self::PARAMETER); - if (\is_string($value) && self::DEFAULT_VALUE === ($parameters[self::PARAMETER] ?? null)) { + if (\is_string($value)) { $container->setParameter(self::PARAMETER, $value); } } diff --git a/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php b/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php new file mode 100644 index 0000000..daec49c --- /dev/null +++ b/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php @@ -0,0 +1,45 @@ +createStub(ProcessExecutionRepository::class), '/logs', $this->createStub(TranslatorInterface::class)); + new ProcessExecutionCrudController($this->createStub(ProcessExecutionRepository::class), '/logs'); + } finally { + restore_error_handler(); + } + + self::assertSame( + ['Since cleverage/ui-process-bundle 3.4: Passing a translator to "'.ProcessExecutionCrudController::class.'::__construct()" is deprecated, it is not used. The argument will be removed in 4.0.'], + $deprecations + ); + } +} diff --git a/tests/DependencyInjection/Compiler/UploadDirectoryParameterPassTest.php b/tests/DependencyInjection/Compiler/UploadDirectoryParameterPassTest.php index d9c80d4..df86e65 100644 --- a/tests/DependencyInjection/Compiler/UploadDirectoryParameterPassTest.php +++ b/tests/DependencyInjection/Compiler/UploadDirectoryParameterPassTest.php @@ -33,11 +33,6 @@ public static function provideParameters(): iterable yield 'defaults' => [[], '/app/var/storage/uploads', []]; yield 'new parameter set' => [['cleverage_ui_process.upload_directory' => '/app/var/imports'], '/app/var/imports', []]; yield 'deprecated parameter set' => [['upload_directory' => '/app/var/legacy'], '/app/var/legacy', [self::SETTING_DEPRECATION]]; - yield 'both set: the new one wins' => [ - ['upload_directory' => '/app/var/legacy', 'cleverage_ui_process.upload_directory' => '/app/var/imports'], - '/app/var/imports', - [self::SETTING_DEPRECATION], - ]; } /** @@ -70,6 +65,23 @@ public function testProcess(array $applicationParameters, string $expectedDirect self::assertSame([self::READING_DEPRECATION], $deprecations); } + public function testAnApplicationParameterIsLeftAloneWhenBothAreSet(): void + { + $container = new ContainerBuilder(); + $container->setParameter(UploadDirectoryParameterPass::PARAMETER, '/app/var/imports'); + // e.g. a parameter of another bundle + $container->setParameter(UploadDirectoryParameterPass::DEPRECATED_PARAMETER, '/app/var/other'); + + $deprecations = $this->collectDeprecations(static function () use ($container): void { + (new UploadDirectoryParameterPass())->process($container); + $container->getParameter(UploadDirectoryParameterPass::DEPRECATED_PARAMETER); + }); + + self::assertSame([], $deprecations); + self::assertSame('/app/var/imports', $container->getParameter(UploadDirectoryParameterPass::PARAMETER)); + self::assertSame('/app/var/other', $container->getParameter(UploadDirectoryParameterPass::DEPRECATED_PARAMETER)); + } + public function testWithoutDeprecatedParameter(): void { $container = new ContainerBuilder(); From da2e1faf2969d432fa0095d0810dadae3f7203c3 Mon Sep 17 00:00:00 2001 From: Nicolas Joubert Date: Fri, 23 Oct 2026 10:28:19 +0200 Subject: [PATCH 2/2] #216 - Deprecation of the $translator argument: documented under v3.3 in UPGRADE.md, notice since 3.3 (the argument is deprecated since 3.3) Co-Authored-By: Claude Opus 5.5 (1M context) --- UPGRADE.md | 14 ++++++-------- .../Admin/ProcessExecutionCrudController.php | 4 ++-- .../Admin/ProcessExecutionCrudControllerTest.php | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index fd37c27..9d2fffb 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,14 +1,6 @@ Upgrade Guide ============= -## Latest - -### Process executions controller - -The `$translator` argument of `ProcessExecutionCrudController::__construct()` is deprecated (it is not used since 3.3, -the duration format being defined in the `admin/field/duration.html.twig` template): passing it triggers a deprecation, -it will be removed in 4.0. Only an application that redefines this controller service is concerned. - ## v3.3 ### Route names @@ -61,6 +53,12 @@ removed in 4.0: update your templates (e.g. overridden templates of the bundle). | `resolve_ui_options()` | `cleverage_ui_process_resolve_ui_options()` | | `md5` (filter) | `cleverage_ui_process_md5` (filter) | +### Process executions controller + +The `$translator` argument of `ProcessExecutionCrudController::__construct()` is deprecated (it is not used since 3.3, +the duration format being defined in the `admin/field/duration.html.twig` template): passing it triggers a deprecation, +it will be removed in 4.0. Only an application that redefines this controller service is concerned. + ### Process bundle 5.4 `cleverage/process-bundle` `^5.4` is required: follow its diff --git a/src/Controller/Admin/ProcessExecutionCrudController.php b/src/Controller/Admin/ProcessExecutionCrudController.php index a394c83..a065a6f 100644 --- a/src/Controller/Admin/ProcessExecutionCrudController.php +++ b/src/Controller/Admin/ProcessExecutionCrudController.php @@ -46,7 +46,7 @@ class ProcessExecutionCrudController extends AbstractCrudController { /** - * @param TranslatorInterface|null $translator deprecated since 3.4, no longer used (the duration format is defined in + * @param TranslatorInterface|null $translator deprecated since 3.3, no longer used (the duration format is defined in * the admin/field/duration.html.twig template), will be removed in 4.0 * @param int $staleAfter seconds without heartbeat after which a started execution is * considered as not responding @@ -58,7 +58,7 @@ public function __construct( private readonly int $staleAfter = 900, ) { if ($translator instanceof TranslatorInterface) { - trigger_deprecation('cleverage/ui-process-bundle', '3.4', 'Passing a translator to "%s::__construct()" is deprecated, it is not used. The argument will be removed in 4.0.', self::class); + trigger_deprecation('cleverage/ui-process-bundle', '3.3', 'Passing a translator to "%s::__construct()" is deprecated, it is not used. The argument will be removed in 4.0.', self::class); } } diff --git a/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php b/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php index daec49c..7ef77ae 100644 --- a/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php +++ b/tests/Controller/Admin/ProcessExecutionCrudControllerTest.php @@ -38,7 +38,7 @@ public function testPassingATranslatorIsDeprecated(): void } self::assertSame( - ['Since cleverage/ui-process-bundle 3.4: Passing a translator to "'.ProcessExecutionCrudController::class.'::__construct()" is deprecated, it is not used. The argument will be removed in 4.0.'], + ['Since cleverage/ui-process-bundle 3.3: Passing a translator to "'.ProcessExecutionCrudController::class.'::__construct()" is deprecated, it is not used. The argument will be removed in 4.0.'], $deprecations ); }