Skip to content

Conversation

ttskch
Copy link
Contributor

@ttskch ttskch commented Oct 18, 2025

Q A
Branch? main
Tickets N/A
License MIT
Doc PR N/A

We discovered an issue where a circular dependency could occur when decorating a system processor such as WriteProcessor.

For example, create a decorator for WriteProcessor called AppWriteProcessor as follows:

$this->app->extend(WriteProcessor::class, function (WriteProcessor $inner) {
return new AppWriteProcessor($inner);
});
final class AppWriteProcessor implements ProcessorInterface
{
public function __construct(
private readonly WriteProcessor $decorated,
) {
}

public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): mixed
{
return $this->decorated->process($data, $operation, $uriVariables, $context);
}
}

In this case, because AppWriteProcessor implements ProcessorInterface, it is tagged with ProcessorInterface and is therefore included as a dependency of CallableProcessor.

Furthermore, because CallableProcessor is included in the dependencies of WriteProcessor, a circular dependency occurs: CallableProcessor -> AppWriteProcessor -> WriteProcessor -> CallableProcessor.

The only two ways to prevent this is to change the constructor argument type of AppWriteProcessor to mixed instead of WriteProcessor, or to remove the tagging of AppWriteProcessor with ProcessorInterface.

This PR introduces a new SkipAutoconfigure attribute, which allows you to exclude some application code from autoconfigure.

I've created a minimal environment to reproduce this issue in the following GitHub repository, and the commit logs explain the process to resolve it.

https://github.com/ttskch/api-platform-laravel-system-provider-decoration-example/commits/main/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant