SQLite path resolution misses db-path.php secret path
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
调研方向
Start with src/DB_Command_SQLite.php:65-99 and compare its path resolution with Automattic/wp-cli-sqlite-command/src/SQLiteDriverFactory.php:46-78 and the drop-in logic in wp-includes/sqlite/db.php:50-56. Reproduce with DB_PATH outside wp-content/database before FQDB is defined, then check the wp db file-path commands. Done when those commands resolve the explicit or recorded database path instead of the default .ht.sqlite.
由索引模型根据 Issue 内容生成。
描述
Problem
DB_Command_SQLite::get_sqlite_db_path() (src/DB_Command_SQLite.php:65-99) only checks, in order:
FQDBconstant,FQDBDIR+DB_FILE, defaulting to<wp-content>/database/.ht.sqlite,- a few hardcoded legacy fallbacks.
Since sqlite-database-integration 3.1, the canonical resolution lives in the drop-in (wp-includes/sqlite/db.php:50-56):
if ( defined( 'DB_PATH' ) ) {
$database_storage = WP_SQLite_Storage::with_explicit_path( DB_PATH );
} elseif ( defined( 'FQDB' ) ) {
$database_storage = WP_SQLite_Storage::with_explicit_path( FQDB );
} else {
$database_storage = WP_SQLite_Storage::with_secret_path( FQDBDIR );
}
with_secret_path() reads the recorded randomized path from db-path.php (class-wp-sqlite-storage.php:118-126,386-407), migrating legacy .ht.sqlite (:204-210). Sites that set an explicit DB_PATH outside the web root (in our case, .local/sqlite/wordpress.sqlite via WP_DB_PATH) cannot be located by wp db * file-path operations whenever the drop-in has not yet defined FQDB. Until then, wp db export, size, and reset resolve the wrong file or report a missing database.
The sibling package already handles this. See Automattic/wp-cli-sqlite-command/src/SQLiteDriverFactory.php:46-78, which resolves DB_PATH → FQDB → FQDBDIR/db-path.php (@include) → legacy .ht.sqlite → with_secret_path(FQDBDIR)->initialize().
Proposed change
The same chain should be mirrored in get_sqlite_db_path(): check DB_PATH first, then FQDB, then @include FQDBDIR/db-path.php, then legacy .ht.sqlite. Alternatively, once the drop-in is loaded, the function could return the already-resolved FQDB, which the drop-in re-defines from the resolved path at db.php:75-77.
Repro
Set DB_PATH to a file outside wp-content/database, with no FQDB defined yet at the point wp db resolves the path. Run any wp db file-path subcommand. It targets <wp-content>/database/.ht.sqlite.
- 主要语言
- PHP
- 星标
- 76
- 派生
- 74
- 平均合并
- 2 小时 50 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
wp-cli/db-command 的其他 Issue
-
db tail command未关闭command:db status:unconfirmed
难度 4/5 3-5 天 新手友好度 45/100
wp-cli/db-command#359 ·
-
Size: separate data_length and index_length可能已有人在做 @swissspidy 于 57 天前认领。 未关闭command:db-size scope:documentation
难度 3/5 1-2 天 新手友好度 65/100
wp-cli/db-command#348 · 1 条评论 ·
-
query shouldn't require mysql/mariadb cli tools可能已有人在做 @swissspidy 于 223 天前认领。 未关闭bug command:db-query
wp-cli/db-command#319 · 5 条评论 · 1 个 reaction · 已指派 2 人 ·
-
Add `wp db status` command for quick database health overview可能已有人在做 @swissspidy 于 283 天前认领。 未关闭command:db scope:distribution state:unconfirmed
wp-cli/db-command#306 · 5 条评论 · 1 个 reaction · 已指派 2 人 ·
-
Giving multiple same arguments to mysqldump (via wp db export) only forwards the latest可能已有人在做 @astappiev 于 398 天前认领。 未关闭bug command:db-export
难度 3/5 1-2 天 新手友好度 45/100
wp-cli/db-command#289 · 3 条评论 ·
查看 wp-cli/db-command 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 3 天内回复
-
sync-en
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
[Sync EN] Formatting improvements to "Large Objects (LOBs)" docs (#6056)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭sync-en
难度 1/5 1 小时以内 新手友好度 74/100
维护者通常 1 天内回复
-
Перевод устарел
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
repo:cms
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复