Skip to content

Commit 19f61ba

Browse files
Merge pull request #217 from cleverage/216
#216 - Cookbooks with task codes, application `upload_directory` parameter left alone, deprecation notice for the unused `$translator` argument, scheduler log levels
2 parents ee27035 + 75dbaaa commit 19f61ba

12 files changed

Lines changed: 99 additions & 26 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Latest
22
------
33

4+
### Changes
5+
* [#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.
6+
47
## Changes
58
* [#220](https://github.com/cleverage/ui-process-bundle/issues/220) A process stopped on purpose by a `StopTask` (e.g. not going on when the source file does not exist) is recorded with the `stopped` status, and notified as `stopped`, instead of `finish`. Requires the process bundle version providing `ProcessEvent::isProcessStopped()` (cleverage/process-bundle#337); with an older version, the execution keeps the `finish` status. Update documentation, add tests.
69
* [#207](https://github.com/cleverage/ui-process-bundle/issues/207) The `main` firewall configured by the bundle (`security.configure_firewall`) limits the login attempts (Symfony `login_throttling`, default settings: 5 failed attempts per minute for a username and an IP address, 25 for an IP address); the settings can be changed in the application firewall. Require `symfony/rate-limiter`. Update documentation and tests.

‎UPGRADE.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ removed in 4.0: update your templates (e.g. overridden templates of the bundle).
5353
| `resolve_ui_options()` | `cleverage_ui_process_resolve_ui_options()` |
5454
| `md5` (filter) | `cleverage_ui_process_md5` (filter) |
5555

56+
### Process executions controller
57+
58+
The `$translator` argument of `ProcessExecutionCrudController::__construct()` is deprecated (it is not used since 3.3,
59+
the duration format being defined in the `admin/field/duration.html.twig` template): passing it triggers a deprecation,
60+
it will be removed in 4.0. Only an application that redefines this controller service is concerned.
61+
5662
### Process bundle 5.4
5763

5864
`cleverage/process-bundle` `^5.4` is required: follow its

‎config/services/controller.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ services:
6262
arguments:
6363
$processExecutionRepository: '@cleverage_ui_process.repository.process_execution'
6464
$logDirectory: '%kernel.logs_dir%'
65-
$translator: '@translator'
6665
# $staleAfter: set by the extension (process_execution.stale_after)
6766
calls:
6867
- [setContainer, ['@Psr\Container\ContainerInterface']]

‎docs/cookbooks/form_file_upload.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ clever_age_process:
3838
message: 'delimiter context must be , or ;. {{ value }} given.'
3939
tasks:
4040
log_file:
41-
service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask'
41+
task: logger
4242
options:
4343
level: info
4444
message: 'Read file'
4545
context: ['input']
4646
outputs: [read]
4747

4848
read:
49-
service: '@CleverAge\ProcessBundle\Task\File\Csv\InputCsvReaderTask'
49+
task: input_csv_reader
5050
options:
5151
delimiter: '{{ delimiter }}' # Contextualized option, set from the launch form
5252
outputs: [log_line]
5353

5454
log_line:
55-
service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask'
55+
task: logger
5656
options:
5757
level: info
5858
message: 'Read line'

‎docs/cookbooks/http_api_launch.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ clever_age_process:
1818
target: Logs
1919
tasks:
2020
request:
21-
service: '@CleverAge\RestProcessBundle\Task\RequestTask'
21+
task: rest_request
2222
options:
2323
client: apicarto_ign
2424
url: '/codes-postaux/communes/{codePostal}'
@@ -27,14 +27,14 @@ clever_age_process:
2727
outputs: [decode]
2828

2929
decode:
30-
service: '@CleverAge\ProcessBundle\Task\TransformerTask'
30+
task: transformer
3131
options:
3232
transformers:
3333
json_decode: ~ # Generic transformer defined in the application
3434
outputs: [log]
3535

3636
log:
37-
service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask'
37+
task: logger
3838
options:
3939
level: info
4040
message: 'Communes fetched'

‎docs/cookbooks/scheduled_process.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ clever_age_process:
2222
value: King
2323
tasks:
2424
read:
25-
service: '@CleverAge\DoctrineProcessBundle\Task\EntityManager\DoctrineReaderTask'
25+
task: doctrine_reader
2626
options:
2727
class_name: 'App\Entity\Author'
2828
criteria:
2929
lastname: '{{ lastname }}' # Contextualized option, set by the schedule
3030
outputs: [log, remove]
3131

3232
log:
33-
service: '@CleverAge\ProcessBundle\Task\Reporting\LoggerTask'
33+
task: logger
3434
options:
3535
level: warning # Counted in the execution report
3636
message: 'Removing author'
3737

3838
remove:
39-
service: '@CleverAge\DoctrineProcessBundle\Task\EntityManager\DoctrineRemoverTask'
39+
task: doctrine_remover
4040
```
4141
4242
Then, in the UI, open "Process > Scheduler" and create a schedule:

‎docs/reference/01-bundle_configuration.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Container parameters
9898
|-----------------------------------------|-------------------------------------------|-------------|
9999
| `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. |
100100
| `cleverage_ui_process.delete_uploaded_files` | `true` | Delete the uploaded file once the process has been executed (successfully or not), by the Messenger handler or by the HTTP API when the process is not queued. Only the files of `cleverage_ui_process.upload_directory` are deleted. Set it to `false` to keep them, e.g. when a process stores the path of its input. |
101-
| `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. |
101+
| `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. |
102102

103103
It can be overridden in your application:
104104

‎docs/reference/05-scheduler.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ How it works
2525

2626
- The bundle registers a schedule provider named `cron` (`CleverAge\UiProcessBundle\Scheduler\CronScheduler`), so
2727
Symfony creates the `scheduler_cron` transport. It builds a recurring message for each valid and enabled
28-
`ProcessSchedule`. Invalid schedules are skipped and logged (`info` level, `scheduler` channel).
28+
`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.
2929
- When a schedule is due, the `scheduler_cron` worker receives a `CronProcessMessage`. It reads the schedule again
3030
from the database: if it has been disabled or deleted since, the process is not run (logged, `info` level,
3131
`scheduler` channel). Otherwise, it dispatches a `ProcessExecuteMessage` (with the current schedule input and

‎src/Controller/Admin/ProcessExecutionCrudController.php‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,20 @@
4646
class ProcessExecutionCrudController extends AbstractCrudController
4747
{
4848
/**
49-
* @param TranslatorInterface $translator deprecated, no longer used (the duration format is defined in the
50-
* admin/field/duration.html.twig template), will be removed in 4.0
51-
* @param int $staleAfter seconds without heartbeat after which a started execution is considered
52-
* as not responding
49+
* @param TranslatorInterface|null $translator deprecated since 3.3, no longer used (the duration format is defined in
50+
* the admin/field/duration.html.twig template), will be removed in 4.0
51+
* @param int $staleAfter seconds without heartbeat after which a started execution is
52+
* considered as not responding
5353
*/
54-
public function __construct(// @phpstan-ignore constructor.unusedParameter ($translator deprecated, kept for BC)
54+
public function __construct(
5555
private readonly ProcessExecutionRepository $processExecutionRepository,
5656
private readonly string $logDirectory,
57-
TranslatorInterface $translator,
57+
?TranslatorInterface $translator = null,
5858
private readonly int $staleAfter = 900,
5959
) {
60+
if ($translator instanceof TranslatorInterface) {
61+
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);
62+
}
6063
}
6164

6265
public static function getEntityFqcn(): string

‎src/DependencyInjection/Compiler/UploadDirectoryParameterPass.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
/**
2020
* The "upload_directory" parameter is deprecated since 3.3 for "cleverage_ui_process.upload_directory": when the
21-
* application still overrides it, its value is used (unless the new parameter is also set), with a deprecation.
22-
* Reading it is deprecated too.
21+
* application still overrides it, its value is used, with a deprecation. Reading it is deprecated too. When the
22+
* application also sets "cleverage_ui_process.upload_directory", its "upload_directory" parameter is its own (e.g. for
23+
* another bundle): it is left alone, without deprecation.
2324
*
2425
* @internal
2526
*/
@@ -40,9 +41,13 @@ public function process(ContainerBuilder $container): void
4041
}
4142

4243
$value = $parameters[self::DEPRECATED_PARAMETER];
44+
if (self::DEPRECATED_DEFAULT_VALUE !== $value && self::DEFAULT_VALUE !== ($parameters[self::PARAMETER] ?? null)) {
45+
// Both parameters are set: "upload_directory" is a parameter of the application, unrelated to the bundle
46+
return;
47+
}
4348
if (self::DEPRECATED_DEFAULT_VALUE !== $value) {
4449
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);
45-
if (\is_string($value) && self::DEFAULT_VALUE === ($parameters[self::PARAMETER] ?? null)) {
50+
if (\is_string($value)) {
4651
$container->setParameter(self::PARAMETER, $value);
4752
}
4853
}

0 commit comments

Comments
 (0)