Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Latest
## Fixes
* [#143](https://github.com/cleverage/process-bundle/issues/143) Fix InputIteratorTask: an `\IteratorAggregate` input whose `getIterator()` does not return an `\Iterator` (e.g. another `\IteratorAggregate`) is iterated instead of failing with a `TypeError`. Update documentation, add tests.
* [#143](https://github.com/cleverage/process-bundle/issues/143) Fix level 8 edge cases failing with a `TypeError` or an `Error`: `CsvResource` rejects a blank header line and checks `ftell()`, XpathEvaluatorTransformer throws an explicit `\UnexpectedValueException` on an invalid query (with the libxml messages), a namespace node to unwrap or a node without document, SlugifyTransformer on a value that cannot be transliterated, `ProcessState::getContext()` returns `[]` until the context is defined, GenericTransformer and TransformerTrait throw a `\LogicException` when not initialized, IterableBatchTask and JsonStreamReaderTask can be flushed / iterated before their first execution, RegistryCompilerPass checks its configuration, SubprocessInstance checks the PHP executable. Update documentation, add tests.
* [#239](https://github.com/cleverage/process-bundle/issues/239) Fix PropertyGetterTask: catch any `\Throwable`, so that the `TypeError` of the property accessor on a scalar input is set on the state (with the `property` error context) and handled according to the task `error_strategy` instead of escaping it. Update documentation, add tests.

v5.1
-----
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/tasks/property_getter_task.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Possible outputs

`mixed`: the value read at the `property` path.

If the value cannot be read, the exception is set on the state (with the `property` added to the error context) and
handled according to the task `error_strategy`.
If the value cannot be read (including a `\TypeError` of the property accessor, e.g. on a scalar input), the exception
is set on the state (with the `property` added to the error context) and handled according to the task `error_strategy`.

Options
-------
Expand Down
2 changes: 1 addition & 1 deletion src/Task/PropertyGetterTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function execute(ProcessState $state): void

try {
$output = $this->accessor->getValue($input, $property);
} catch (\Exception $e) {
} catch (\Throwable $e) {
$state->addErrorContextValue('property', $property);
$state->setException($e);

Expand Down
10 changes: 10 additions & 0 deletions tests/Task/PropertyGetterTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ public function testPropertyPathOnArraySetsExceptionWithErrorContext(): void
self::assertNull($state->getOutput());
}

public function testScalarInputSetsExceptionWithErrorContext(): void
{
// The PropertyAccessor throws a \TypeError (not an \Exception) on a scalar input
$state = $this->execute('[sku]', 'foo');

self::assertInstanceOf(\TypeError::class, $state->getException());
self::assertSame(['property' => '[sku]'], $state->getErrorContext());
self::assertNull($state->getOutput());
}

public function testMissingPropertyOptionIsRejected(): void
{
$this->expectException(MissingOptionsException::class);
Expand Down
Loading