forked from zfcampus/zf-rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Prevent circular dependency lookup in RpcControllerFactory
As reported in zfcampus#18, a circular dependency lookup can occur when specifying a static method of a class as a `callable` for an RPC service that matches the class name for the RPC service. As an example: ```php return [ 'zf-rpc' => [ SomeController::class => [ 'callable' => SomeController::class . '::bar', ], ], ]; ``` In the above case, the `RpcControllerFactory` would be invoked for `SomeController::class`, find the `callable` entry of `{NS}\SomeController::bar`, split this into the class and method, and then attempt to fetch `SomeController::class` again, ad infinitum. This patch adds a private property, `$lastRequestedControllerService`, which is set to the service being pulled whenever we attempt to marshal a service from the controller manager. If a subsequent invocation finds that the service requested matches that property value, then we do not attempt to pull from the controller manager again, but move on to the parent container (if we have one), or directly instantiating the class. (The `$lastRequestedControllerService` is reset otherwise.) Fixes zfcampus#18
- Loading branch information
1 parent
c03f498
commit 474fcb4
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters