|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-12-08 18:25 UTC] julien dot boudry at gmail dot com
Description:
------------
Impossible to unlink an SQLite file after destroying his PDO object. Not reproducible in any context, but happen with circular references.
On Windows only, PHP 7.3 and PHP 7.4.0 (not tested on lower versions).
Test script:
---------------
<?php
class Test {
public static $path;
protected $base;
protected $prepare = [];
protected $myContainer;
public function __construct (Container $myContainer)
{
$this->myContainer = $myContainer;
self::$path = getcwd().'/base.sqlite';
$this->base = new PDO ('sqlite:'.self::$path,'','',[\PDO::ATTR_PERSISTENT => false]);
$this->base->query('CREATE TABLE IF NOT EXISTS test (col_a INTEGER PRIMARY KEY NOT NULL)');
$this->prepare[] = $this->base->prepare('INSERT INTO test VALUES (1)');
}
}
class Container
{
protected $myTest;
public function __construct () {
$this->myTest = new Test ($this);
}
}
$container = new Container;
unset($container);
unlink(Test::$path);
Expected result:
----------------
Not any output or warning and File bdd.sqlite destroy. On Linux it's working as expected.
Actual result:
--------------
PHP Warning: unlink(C:\php-script/base.sqlite): Resource temporarily unavailable in C:\php-script\pdo.php on line 40
PHP Stack trace:
PHP 1. {main}() C:\php-script\pdo.php:0
PHP 2. unlink() C:\php-script\pdo.php:40
Warning: unlink(C:\php-script/base.sqlite): Resource temporarily unavailable in C:\php-script\pdo.php on line 40
Call Stack:
0.4049 396904 1. {main}() C:\php-script\pdo.php:0
0.4073 398376 2. unlink() C:\php-script\pdo.php:40
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 16:00:01 2025 UTC |
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.