-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Request & Response objects stored multiple times #4580
Comments
All the classes you referenced use |
If we add that ci4 can be used inside another framework class myFramework {
...
$this->app = require realpath($bootstrap) ?: $bootstrap;
} means that Some objects are stored 4 times .
|
I don't believe this is accurate. I wasn't able to find information confirming or denying it (except for one StackOverflow from six years ago that was deemed a bug). But the article you linked doesn't apply to your statement at all. Doctrine Proxies look cool but we won't be using them. The framework as a whole uses something akin to what that article seems "Service Location", but with some of the concerns addressed. I still see no compelling evidence that our implementation represents any performance concerns. |
Obviously we have no control over anyone else would choose to implement mixing CI with their own framework. However, if they choose to use the Services class then the shared instances is still a thing. Unlike the example you pointed to, CI doesn't require passing an instance of a ServiceLocator class around, it uses static methods which keeps it at a single instance. If it did, there's still ways around getting multiple instances of a ServiceLocator class, one of which would be to create a single instance in your controller, and then manually inject the dependency. However, most frameworks have some form of DI container that handles instance control for you, so that shouldn't be a problem anyway. And when passed into a class/method, it's not the entire object that's being passed in, it's a class identifier that points to the object itself. See: https://www.php.net/manual/en/language.oop5.references.php Unless you can provide a concrete example of this happening that is within the control of the framework I'll have to agree with @MGatner and say that I've seen no compelling evidence of this being an issue with the current implementation. |
True . Investigating pivetta's contribution on this matter on zend framework , and doing some benchmarks on ci4 storing 4 -40 instances of( IncomingRequest and Response) or calling services each time , there is just a little difference in speed , and memory usage . |
Request & Response objects stored multiple times
CodeIgniter\Config\BaseService $instances
CodeIgniter\CodeIgniter $request,$response;
CodeIgniter\Controller $request,$response .
More objects share same duplication fate (Logger,Validation ... ... ) .
CodeIgniter 4 version
All
The text was updated successfully, but these errors were encountered: