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分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 件 · 担当者 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 件 · 担当者 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)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンsync-en
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
Перевод устарел
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
repo:cms
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
craftcms/cms#20613 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信