Bug #78930 [Nab]: PDO Sqlite not close connection after destruction (windows only)
| From: | requinix@php.net | Date: | Sun, 08 Dec 2019 19:55:59 +0000 |
| Subject: | Bug #78930 [Nab]: PDO Sqlite not close connection after destruction (windows only) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224137@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78930&edit=1
ID: 78930
Updated by: requinix@php.net
Reported by: julien dot boudry at gmail dot com
Summary: PDO Sqlite not close connection after destruction
(windows only)
Status: Not a bug
Type: Bug
Package: PDO SQLite
Operating System: Windows only
PHP Version: 7.4.0
Block user comment: N
Private report: N
New Comment:
I see now, the behavior is a bit different.
That prepared statement you created is keeping the SQLite resource in use. You have to unset $base
as well as $prepare.
Previous Comments:
------------------------------------------------------------------------
[2019-12-08 19:39:41] julien dot boudry at gmail dot com
You're right, exactly the same, it's working.
But. If I had a destructor (and change a visibility), it fails again.
Look only the last revision here (or the last version).
https://gist.github.com/julien-boudry/6672e4e98e48b14fc6a6871942a6ef2b/revisions
------------------------------------------------------------------------
[2019-12-08 19:27:53] requinix@php.net
> Even if I add gc_collect_cycles(); just before last line with unlink call. It's not
> working better.
> I do not seem to have any convincing solution for my use case.
Adding gc_collect_cycles() works for me. Are you running the *exact* code you posted but with a
gc_collect_cycles();
added immediately before the unlink()?
------------------------------------------------------------------------
[2019-12-08 19:22:03] julien dot boudry at gmail dot com
Hi,
Even if I add gc_collect_cycles(); just before last line with unlink call. It's not working
better. I do not seem to have any convincing solution for my use case.
I would like to make it clear that if I do not produce any circular references. Then the unlink
works correctly under windows.
------------------------------------------------------------------------
[2019-12-08 19:12:51] requinix@php.net
Windows does not allow deleting files while there are open handles to it. Linux does.
Clean up the circular reference with gc_collect_cycles().
https://www.php.net/manual/en/features.gc.php
------------------------------------------------------------------------
[2019-12-08 18:39:30] julien dot boudry at gmail dot com
If I comment the line 17:
// $this->myContainer = $myContainer;
It's working.
--
Even if I add a destructor on Test class:
public function __destruct () {
$this->myContainer = null;
}
If not working too.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=78930
--
Edit this bug report at https://bugs.php.net/bug.php?id=78930&edit=1