php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61572 Changed SQLite behavior (sqlite_close)
Submitted: 2012-03-30 16:44 UTC Modified: 2017-10-24 23:31 UTC
Votes:9
Avg. Score:4.2 ± 0.6
Reproduced:9 of 9 (100.0%)
Same Version:5 (55.6%)
Same OS:6 (66.7%)
From: per at esmannjensen dot dk Assigned:
Status: Suspended Package: SQLite (PECL)
PHP Version: 5.3.10 OS: Linux, perhaps all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: per at esmannjensen dot dk
New email:
PHP Version: OS:

 

 [2012-03-30 16:44 UTC] per at esmannjensen dot dk
Description:
------------
In PHP 5.2 the test script below works fine, but in PHP 5.3 it does not work.  As 
far as I know this difference is not documented.

To make the script work in PHP 5.3, you would have to move the sqlite_close 
command to the end of the script or comment it out.

It seems to me that the return handle ($res in the test script) does not survive 
sqlite_close in PHP 5.3. But I am not savvy enough to be sure about this.

Test script:
---------------
<?php

$db = sqlite_open('path/to/database');
$sql = "SELECT * FROM mytable";
$res = sqlite_query($sql, $db);
sqlite_close($db);

while ( $thisRow = sqlite_fetch_array($res) )
{
   print_r($thisRow);
}

?>

Expected result:
----------------
The documentation should be clear about this difference.

Due to potential concurrency problems in SQLite, developers may have chosen to 
close the database handle ASAP in their PHP 5.2 scripts. While upgrading to PHP 
5.3 they may need a hint that "ASAP" has changed.

Actual result:
--------------
PHP 5.2: Every row in mytable is printed out via print_r()

PHP 5.3: "Warning: sqlite_fetch_array(): 3 is not a valid sqlite result resource 
in /server/path/test-script.php on line 8"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-02-01 10:17 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 [2014-02-01 10:17 UTC] krakjoe@php.net
This bug is reported for an unsupported version of PHP and is not connected to security.

(In addition, the sqlite extension is superseded by sqlite3)

It is therefore being closed.

If the bug is still present in a stable, supported version of PHP, please do open a new bug report.

Thanks for taking the time to help make PHP better :)
 [2014-02-01 13:28 UTC] salathe@php.net
-Status: Closed +Status: Re-Opened -Assigned To: krakjoe +Assigned To:
 [2014-02-01 13:28 UTC] salathe@php.net
Regardless of whether the PHP v5 version is supported or not, there should still be changelog entries on the appropriate manual page(s).
 [2015-08-31 16:39 UTC] cmb@php.net
The behavioral change seems to be the result of fixing bug
#42203[1].

[1] <https://github.com/php/php-src/commit/32c03b5>
 [2017-10-24 23:31 UTC] kalle@php.net
-Status: Re-Opened +Status: Suspended
 [2017-10-24 23:31 UTC] kalle@php.net
The SQLite extension was moved out of the PHP source and back in to PECL and have not since had a release or any activity, I would highly suggest to use the bundled sqlite3 extension instead. If development begins at this extension, then this report should be re-opened
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jan 19 07:01:23 2020 UTC