Repository navigation
Conversation
…db` pushes it
sqlite-database-integration 3.x (which Playground downloads at latest) moves the
DB to wp-content/database/.ht.<hex>/.ht.sqlite and records it in db-path.php.
pushDatabase() and the isClone check only looked at the legacy .ht.sqlite, so
`local push --with-db` pushed files and then skipped the DB ("No local database
found") on every OS.
Add resolveLocalSqlitePath(): db-path.php (parsed, never executed; must resolve
inside wp-content/database) -> .ht.*/.ht.sqlite (newest mtime, warns if several)
-> legacy .ht.sqlite. Use it in pushDatabase() and buildServerArgs()' isClone.
The clone import already wipes wp-content/database before writing .ht.sqlite;
documented why that is load-bearing (a leftover db-path.php would win).
ClickUp: https://app.clickup.com/t/14ypaj0z2fb
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew fixes - resolvePushSqlitePath(): WP_SQLite_Storage treats db-path.php as the authority, so when it exists but its target is missing/outside/unparseable every fallback is a DB WordPress is not using. local push now refuses instead of overwriting the cloud with it (even with --force). - Warn on a lone .ht.*/ match too (WordPress never scans for these dirs). - readdir/stat failures are 'not found', not a throw (isClone runs on every start). - Tests: glob-before-legacy order, symlinked instance path, push refusal cases, buildServerArgs isClone wiring (exported for the test), db dir is a file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Ready for QA at e63ee6b. Code review (code-reviewer agent): round 1 WARN, round 2 PASS. Branch is frozen while QA (tsk_a2b451b455fe3e83) runs; please don't merge before its verdict. |
|
QA: FAIL ❌: the DB-path fix works. Criterion 4 fails on a
Broke at: |
Bug
instawp local push <name> --with-dbpushes files, then skips the DB:✗ No local database found (expected wp-content/database/.ht.sqlite). Skipping DB push.Reported on Windows 11; it happens on every OS.
Root cause
Playground downloads the latest
sqlite-database-integration(3.1.3). ItsWP_SQLite_Storagekeeps the DB atwp-content/database/.ht.<bin2hex(random_bytes(16))>/.ht.sqliteand records the path inwp-content/database/db-path.php(return __DIR__ . '/.ht.<hex>/.ht.sqlite';). On boot it migrates a legacy.ht.sqliteinto that directory.pushDatabase()and theisClonecheck looked only at the legacy.ht.sqlite.Fix
resolveLocalSqlitePath(instance)(src/lib/local-sqlite.ts) is pure fs: no logging, no exit. It checks, in order:db-path.php: the__DIR__ . '/…'literal is parsed with the same regex as instacp #852 and never executed..ht.*/.ht.sqlite: if several exist, the newest by mtime wins and a warning lists them all..ht.sqlite, then.ht.sqlite.php(the plugin migrates both).Every candidate is realpath'd, so symlinks are followed. It must be a non-empty regular file inside
wp-content/database; containment usespath.relative, which is Windows-safe.Call sites:
pushDatabase()→resolvePushSqlitePath(): prints warnings and the chosen DB path before the confirm prompt. When nothing is found, the error lists every path checked. It refuses (even with--force) whendb-path.phpexists but its target is missing, outside the dir or unparseable:WP_SQLite_Storagetreatsdb-path.phpas the authority, so any fallback is a DB WordPress is not using, and pushing it would overwrite the cloud with stale data. A lone.ht.*/match (nodb-path.php) is pushed with a warning.buildServerArgs(),isClone: uses the resolver.wp-content/database(removing anydb-path.phpand old secret dir) before writing.ht.sqlite, and the plugin then migrates it. A comment now explains why that wipe is load-bearing: the plugin reads the recorded path first and ignores a legacy file while the recorded DB exists.Deliberate divergence from instacp #852 / the plugin's own lookup. They try legacy before the glob; this follows the ticket's order (glob before legacy). The two only differ when
db-path.phpis unusable and both a secret dir and a legacy file exist.Behaviour change for QA
isClonenow means "has a persisted DB" at any of the three locations. So alocal createinstance takes the clone-mode mounts from its second start onward. That is how it behaved before plugin 3.x, when.ht.sqliteexisted after the first start.Tests
src/__tests__/local-sqlite.test.ts(25 tests) covers:db-path.phpbeats a stale legacy file and a newer secret dir; glob only; glob before legacy; multi-match by mtime (both orders); unparseabledb-path.php; legacy; none found (lists every path); no db dir; db dir is a file; traversal rejected (a real DB exists at the target); symlinked secret dir rejected; symlinked instance path accepted;buildServerArgsisClone wiring;isInsideDirunderpath.win32.Every mechanism has a mutation that turns a named test red: containment, sort, parser, empty-file check, legacy list, separator check, glob-before-legacy order, dbDir realpath, isClone wiring, refusal, flag set/clear, lone-match warning, readdir guard. Full suite 294/294,
tscclean. Code review (code-reviewer agent): round 1 WARN, no blockers; findings applied in e63ee6b.ClickUp: https://app.clickup.com/t/14ypaj0z2fb
Precedent: InstaWP/instacp#852
Agentric session: https://aos.agents.instawp.net/#/sessions/aos-ses_981564bda5883aa9
Next step (human):
/code-review ultra <this PR>before merge. Do not merge before QA's verdict.— Engineer (agent-os)
🤖 Generated with Claude Code