php / php/php-src

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

Open
#20,076 2 comments 0 reactions 0 assignees View on GitHub

@ndossche is already working on this.

Since Oct 6, 2025.

  • #20080 by @ndossche — open
Bug Extension: pdo_sqlite Extension: sqlite3 Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the sqlite-nomemory.php reproduction on Windows 10 with PHP 8.4.13 and inspect the PDO SQLite handling reached by the PDO constructor. Done means the shown sqlite::memory:?cache=shared connection succeeds without the open_basedir exception; an open pull request is already linked.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sqlite
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.