Skip to content

SQLite: PDOException: open_basedir prohibits opening :memory:?cache=shared #20076

@AnrDaemon

Description

@AnrDaemon

Description

The following code:

#!/usr/bin/env php
<?php

print "open_basedir: ";
var_dump(ini_get("open_basedir"));
print "\n";

$db = new \PDO("sqlite::memory:?cache=shared", null, null, [
    \PDO::ATTR_PERSISTENT => true,
    \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
    \PDO::ATTR_EMULATE_PREPARES => false,
    \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
]);

Resulted in this output:

$ ./sqlite-nomemory.php
open_basedir: string(0) ""

PHP Fatal error:  Uncaught PDOException: open_basedir prohibits opening :memory:?cache=shared in …\sqlite-nomemory.php:8
Stack trace:
#0 …\sqlite-nomemory.php(8): PDO->__construct('sqlite::memo
ry:...', NULL, Object(SensitiveParameterValue), Array)
#1 {main}
  thrown in …\sqlite-nomemory.php on line 8

But I expected this output instead:

I expected no error. Frankly, the code should just work.

PHP Version

PHP 8.4.13 (cli) (built: Sep 23 2025 15:17:09) (ZTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.13, Copyright (c) Zend Technologies
    with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies

Operating System

Windows 10

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions