php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74397 Filename can also be empty string for in-memory db
Submitted: 2017-04-09 15:22 UTC Modified: 2017-04-11 14:13 UTC
From: aarjan at hotmail dot com Assigned: cmb (profile)
Status: Closed Package: SQLite related
PHP Version: 7.0.17 OS: Windows
Private report: No CVE-ID: None
 [2017-04-09 15:22 UTC] aarjan at hotmail dot com
Description:
------------
---
From manual page: http://www.php.net/sqlite3.construct
---
https://github.com/php/php-src/commit/cc125f277b50e0f90fc8033fe7f47d2446389a15

According to this commit, the filename in the constructor may also be an empty string since v7.0.10. This will result in a in-memory database. In previous versions of PHP7 (I tested this with v7.0.2) this would have resulted in a exception. 

The documentation is not mentioning this feature. 

Test script:
---------------
The unit test below works in v7.0.2, but fails in v7.0.17

class SQLiteConstructorTest extends PHPUnit_Framework_TestCase
{
    /**
     * @expectedException Exception
     */
    public function testDefectDatabaseFile()
    {
        $database_file = '';
        $sqlitedb = new SQLite3($database_file);
    }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-09 15:25 UTC] aarjan at hotmail dot com
-Summary: Filename be now also be empty string for in-memory db +Summary: Filename can also be empty string for in-memory db
 [2017-04-09 15:25 UTC] aarjan at hotmail dot com
Typo fix in summary
 [2017-04-11 14:00 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2017-04-11 14:00 UTC] cmb@php.net
> This will result in a in-memory database.

Not quite. If the database name is an empty string, a private,
temporary on-disk database is created.

However, you're right that this has to be properly documented.
 [2017-04-11 14:13 UTC] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=342307
Log: Fix #74397: Filename can also be empty string for in-memory db
 [2017-04-11 14:13 UTC] cmb@php.net
-Status: Verified +Status: Closed
 [2017-04-11 14:13 UTC] cmb@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
 [2020-02-07 06:06 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=d0a57fa419c04ed234b026429e7269df2d5e566e
Log: Fix #74397: Filename can also be empty string for in-memory db
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jan 28 06:01:26 2021 UTC