Bug #78930 [NEW]: PDO Sqlite not close connection after destruction (windows only)
| From: | julien dot boudry at gmail dot com | Date: | Sun, 08 Dec 2019 18:25:51 +0000 |
| Subject: | Bug #78930 [NEW]: PDO Sqlite not close connection after destruction (windows only) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-224131@lists.php.net to get a copy of this message | ||
From: julien dot boudry at gmail dot com
Operating system: Windows only
PHP version: 7.4.0
Package: PDO SQLite
Bug Type: Bug
Bug description:PDO Sqlite not close connection after destruction (windows only)
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
--
Edit bug report at https://bugs.php.net/bug.php?id=78930&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78930&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78930&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78930&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78930&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78930&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78930&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78930&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78930&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78930&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78930&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78930&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78930&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78930&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78930&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78930&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78930&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78930&r=mysqlcfg