php / php/php-src

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

未关闭
#20,076 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@ndossche 已经在做这个了。

开始于 2025年10月6日。

  • #20080 来自 @ndossche —— 未关闭
Bug Extension: pdo_sqlite Extension: sqlite3 Status: Verified
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在 Windows 10 上使用 PHP 8.4.13 运行 sqlite-nomemory.php 复现,并检查通过 PDO 构造函数到达的 PDO SQLite 处理逻辑。显示的 sqlite::memory:?cache=shared 连接在没有 open_basedir 异常的情况下成功建立,即视为完成;一个已打开的 pull request 已经链接。

由索引模型根据 Issue 内容生成。

评估

技术栈
php, sqlite
领域
database
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。