-
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: Set BaseConnection instance as a property of it's property 'lastQuery' cause to 'circular reference' #9386
Comments
CI4 wasn't designed to support long-living PHP - it's quite a different architecture. |
@michalsn Out of context, i'm trying FrankenPHP in my project. But Boot in CI4 need rework to support worker like |
But it's indeed a bug, good programs should not rely on bugs, right? |
I really don't see a bug here. PHP automatically closes database connections at the end of script execution, which is part of its garbage collection process. |
Sorry! It's my mistake, I misunderstanded about that. |
PHP Version
8.1
CodeIgniter4 Version
4.5.4
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
Linux
Which server did you use?
cli
Database
No response
What happened?
Run in a 'Resident Process Mode' such as swoole, a BaseConnection instance would never destruct after query database because of 'circular reference', which means memory leak.
Steps to Reproduce
Query database in a 'Resident Process Mode' such as swoole, echo something in it's __destruct method, nothing will output because the instance won't destruct at all.
Expected Output
The instance should be able to destruct.
Anything else?
Only two methods are used in Query instance: 'isWriteType' and 'escape', which seems could work as static methods. Why not set them as static methods and pass the full class name of BaseConnection instance to Query instance just like
$query = new $queryClass(static::class);
, then we can call those two methods like$this->dbClass::isWriteType($this->originalQueryString)
.Another simpler suggestion is to clone the BaseConnection instance like
$query = new $queryClass(clone $this);
The text was updated successfully, but these errors were encountered: