One deprecation, and some behaviours change: check the points below.
Executing a process while it is already running, by itself or through its sub-processes (A → B → A with the
process_executor task), is deprecated since 5.6 (Since cleverage/process-bundle 5.6: Executing the process "A" while it is already running (A -> B -> A) is deprecated...) and will throw an exception in 6.0. A process has only one set of
task instances and states: the second execution resets them while the first one is running, which then returns the
output of the deepest execution.
Iterate with an iterable task (e.g. a reader or constant_iterable_output followed by process_executor) instead of
recursing, or use the process_launcher task, which runs the process in a separate PHP process. Executing the same
sub-process several times in a row is not concerned.
FinalizableTaskInterface::finalize() is now also called when the process fails, on every task that has been
initialized (not on a task whose initialize() failed, nor on the tasks not reached). A custom finalizable task must not
assume that the process succeeded nor that its data are complete: only release its resources (close files, free
cursors), do not write a footer, move / publish a partial file or run long operations. Check
$state->getProcessHistory()->isFailed() in finalize() to skip such work when the process has failed.
StatCounterTask (stat_counter) now logs its count when the process fails too.
No deprecation in this version. Some behaviours change: check the points below.
A shared service referenced by several tasks of the same process is rejected when the container is compiled
(InvalidArgumentException naming the service, the tasks and the process): all these tasks ran with the same instance,
initialized with the options of each task in turn. Declare your task services with shared: false, as the
autoconfiguration of TaskInterface does since 5.4:
# config/services.yaml
services:
App\Task\MyTask:
shared: falseA process stopped by the stop task (StopTask) is no longer flagged as failed: it is stopped on purpose (e.g. the
source file does not exist). It still ends normally (tasks finalized, cleverage_process.end event, exit code 0, parent
process going on), but:
| Before | After |
|---|---|
ProcessHistory::getState() returns failed |
it returns stopped (ProcessHistory::isStopped()) |
Process <code> failed log, at the failed_level |
Process <code> stopped log, at the success_level |
| nothing tells a stopped process on the end event | ProcessEvent::isProcessStopped() returns true |
To be alerted when a process is stopped, listen to cleverage_process.end and check isProcessStopped(). To stop a
process because of an error, let the error fail it (error strategy stop).
- The process codes and the output format are checked before any process is executed.
- With
--output-format, the output is printed to STDOUT whatever the verbosity (it required-vv): a script reading STDOUT now receives it. - A non-array output that cannot be stored as JSON stream is reported on the error output.
line_reader/input_line_reader: the last line of a file that does not end with a line break is read (it was lost).yaml_writer: a write failure throws aRuntimeException(in production, it was ignored), the parent directory is created if needed.input_csv_reader: an input that is not a path (e.g.null) throws anUnexpectedValueException(instead of a PHP warning followed by aTypeError).array_element/array_last: a position outside the array (or an empty array) givesnull, also in debug mode (it failed with an "Undefined array key" warning); a negativeindexofarray_elementbefore the start of the array givesnullinstead of the first element.file_splitter,csv_splitterand thejson_bufferingofprocess_launchercreate their temporary files readable by their owner only (0600): a process reading them must run with the same user.
ProcessConfigurationRegistry is reset between two messages of a worker (kernel.reset): the task instances and their
states (inputs, outputs, aggregated data) of the last execution are released. A task must not rely on data kept from a
previous message.
Unless stated otherwise, the deprecations below trigger a notice (Since cleverage/process-bundle 5.4: ...) and will be
removed in 6.0.
symfony/process, symfony/stopwatch, symfony/var-dumper, symfony/monolog-bundle and ext-intl are no longer
required, but suggested; symfony/dotenv, symfony/runtime, symfony/error-handler and symfony/monolog-bridge are
removed. Require them in your application if you use them:
| Package | Needed by |
|---|---|
symfony/process |
command_runner and process_launcher tasks |
symfony/stopwatch |
stopwatch task |
symfony/var-dumper |
debug task, dump transformer, --output=- (dump) |
symfony/monolog-bundle |
cleverage_process* log channels and processors |
ext-intl |
slugify transformer |
Without them, the container still compiles: the related tasks and transformer fail with an explicit message when used,
nothing is dumped, and the default logger is used. The doctrine, soap and ui process bundles must be >=3.3.
Referencing a task by its service is deprecated, use its code (given on the reference page of each task):
tasks:
my_task:
# Before (deprecated)
service: '@CleverAge\ProcessBundle\Task\TransformerTask'
# After
task: transformerGive a code to your own tasks with the #[AsTask(code: 'my_task')] attribute (autoconfiguration) or the code
attribute of the cleverage.task tag. Unknown or duplicate codes fail the container compilation.
errorsis deprecated, useerror_outputs(andTaskConfiguration::getErrorOutputs()instead ofgetErrors()). The unusedTaskConfiguration::$logErrorsproperty is deprecated.- An
error_strategyother thanskiporstopis deprecated (it made the process fail at runtime), it will be rejected in 6.0.
Registering a transformer without code is deprecated: declare its code with the #[AsTransformer(code: 'my_code')]
attribute or the code attribute of the cleverage.transformer tag, so that it is only instantiated when used.
# config/services.yaml
App\Transformer\MyTransformer:
tags: [{ name: cleverage.transformer, code: my_code }]TransformerRegistry::addTransformer() is deprecated. TransformerInterface::getCode() is deprecated (no runtime
notice) and will be removed from the interface in 6.0: keep implementing it until then, returning the code of the tag.
- The tasks and transformers of the bundle, and the tasks of your application made public by the
TaskInterfaceautoconfiguration, will be private: fetching them from the service container ($container->get()) is deprecated, use dependency injection. - A task not referenced by the process configurations known at compile time is fetched from the service container, with a deprecation: it will not be found in 6.0.
- The
cleverage_process.event_listener.data_queueservice andDataQueueEventListenerare deprecated (unbounded memory usage): write your own listener of the event dispatched by theevent_dispatchertask. RegistryCompilerPassandCheckSerializerCompilerPassare deprecated (no longer used).
The classes not meant to be extended are marked @final and will be final in 6.0 (engine, registries, models,
configurations, events, concrete tasks and transformers); extending them triggers a deprecation with the Symfony
DebugClassLoader. Type your services on the new interfaces, autowired by the bundle:
| Class | Interface |
|---|---|
ProcessManager |
ProcessManagerInterface |
ProcessConfigurationRegistry |
ProcessConfigurationRegistryInterface |
TransformerRegistry |
TransformerRegistryInterface |
TaskRegistry |
TaskRegistryInterface |
The infrastructure classes (extension, configuration, commands, loggers, Monolog processors...) are @internal.
Only relevant if you instantiate or decorate these services yourself:
| Class | Before (deprecated) | After |
|---|---|---|
ProcessManager |
no TaskRegistry (last argument) |
TaskRegistry |
ProcessHelpCommand |
service container | TaskRegistry |
CommandRunnerTask |
KernelInterface |
%kernel.project_dir% |
ProcessLauncherTask, SubprocessInstance |
KernelInterface |
console path and %kernel.environment% |
The bundle throws its own exceptions implementing ProcessExceptionInterface (InvalidArgumentException,
LogicException, RuntimeException, UnexpectedValueException), extending the SPL exceptions thrown before: existing
catch blocks keep working, and ProcessExceptionInterface now catches all the errors of the bundle.
Setting a target property that is not a simple name (e.g. a.b) as a literal key of an array destination is
deprecated, it will throw an UnexpectedValueException in 6.0. Use the index notation:
mapping:
# Before (deprecated): sets the "a.b" key
a.b: { code: '[source]' }
# After
'[a.b]': { code: '[source]' } # literal key
'[a][b]': { code: '[source]' } # nested arraysWith the event_name option set, the event is dispatched under this name. Listening to EventDispatcherTaskEvent
for such a task is deprecated, listen to the event_name instead.
When the initialization of a task fails, the process goes on with a deprecation. In 6.0, it will fail before executing any task.
The process_options option of the process_launcher task is deprecated (any non-empty value already throws an
exception): remove it from your configurations, it will be removed in 6.0.
The additional_parameters option is deprecated, use right_parameters.