Skip to content
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

Open
warmbook opened this issue Jan 8, 2025 · 2 comments

Comments

@warmbook
Copy link

warmbook commented Jan 8, 2025

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);

@warmbook warmbook added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 8, 2025
@michalsn
Copy link
Member

michalsn commented Jan 8, 2025

CI4 wasn't designed to support long-living PHP - it's quite a different architecture.
You can check this project: https://ciburner.com

@michalsn michalsn removed the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 8, 2025
@ddevsr
Copy link
Collaborator

ddevsr commented Jan 9, 2025

@michalsn Out of context, i'm trying FrankenPHP in my project. But Boot in CI4 need rework to support worker like https://github.com/php-runtime/frankenphp-symfony

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

No branches or pull requests

3 participants