Repository navigation
Description
[RESOLVED — NOT A BUG] The reported fatal was caused by my own test harness (the SQLite
database file was created by a root-privileged wp-cli run and was unreadable by the web server
user). After fixing file ownership, 3.1.3 works flawlessly on WP 7.1.4 / PHP 8.3 & 8.4, including
a fully migrated 339-post site. Root-cause analysis and a UX improvement suggestion are in
this comment.
Safe to close as not-a-bug.
Description
On a clean WordPress 7.1.4 install with the SQLite plugin 3.1.3 active, every web request logs a PHP Fatal error:
PHP Fatal error: Uncaught RuntimeException: Cannot escape data without an active database connection. in /var/www/html/wp-content/plugins/sqlite-database-integration/wp-includes/sqlite/class-wp-sqlite-db.php:324
thrown from class-wp-sqlite-db.php:324 (WP_SQLite_DB::_real_escape(), if ( ! $this->dbh )).
Pages still render with HTTP 200, so the site appears to work — but the fatal is logged on every request (1–3× per request, including wp-cron.php), meaning dbh is not initialized at wp-settings.php:180 (wp_not_installed() → is_blog_installed() → wp_load_alloptions() → esc_sql()).
WP-CLI requests on the same site/database/drop-in never trigger it — the error is specific to the web SAPI context.
Environment
- WordPress 7.1.4 (fresh install)
- PHP 8.4.27 (wordpress:php8.4-apache image), pdo_sqlite loaded
- Plugin 3.1.3 (from wordpress.org stable)
- MySQL 8.4.11 present as the original database (plugin drop-in switches to SQLite)
- Docker (Linux containers), Apache web SAPI
Reproduction (controlled A/B)
Setup A — pristine install. Fresh wordpress:php8.4-apache + MySQL 8.4, image-generated wp-config.php, core installed via wp-cli. Plugin installed from wordpress.org, activated via wp-cli, drop-in written exactly as sqlite_plugin_copy_db_file() does (the db.copy template with placeholders substituted). Fresh empty SQLite database, zero custom content.
Setup B — migrated install. Separate WordPress instance with production-derived wp-config.php, 15-table site (203 posts + custom post type + comments), data converted from a mysqldump and loaded into the SQLite file, W3TC deactivated.
Result: identical fatals in both setups. In Setup A: 9 fatals for 9 web requests (home, ?p=1, wp-cron.php). WP_DEBUG_LOG on, SQLITE_BUSY_TIMEOUT=10000 + SQLITE_JOURNAL_MODE=WAL made no difference. WP-CLI commands (wp post list, wp option get) on the same sites run clean.
Minimal reproduction
- WordPress 7.1.4 on PHP 8.4 with MySQL, plugin 3.1.3 activated
- Enable the SQLite drop-in (admin confirm flow or the
db.copyequivalent) wp core installinto SQLite (fresh)curlthe site home → HTTP 200, butdebug.logcontains the fatal abovewp post listvia CLI on the same site → no error
Expected behavior
No fatal should be logged on a healthy request; _real_escape() should not be reached with an uninitialized dbh during is_blog_installed().
Notes
- The fatal occurs before plugins load (
wp-settings.php:180), so it is not plugin-interference from the site side. - The same drop-in and database work correctly under WP-CLI, which suggests the connection lifecycle (
dbhinitialization) differs between web and CLI contexts. - Happy to provide additional dumps/traces if helpful.
Activity
x-rush commentedon Nov 5, 2026
Correction + additional data points (site is fully broken on the web path)
After posting the report I instrumented a single request (
curl -v) and found the HTTP 200 responses are misleading: the response body is not a rendered page at all — it is a ~1 KB fragment that ends mid-text with the fatal message:So on the web path the site is fully broken (no page ever renders; every request returns a 200-codenamed error fragment). The "pages still render with HTTP 200" wording in the original report should be read as "error fragment returned with a 200 status".
Additional data points:
wordpress:php8.3-apache(PHP 8.3.36): same fatal on every request. Not specific to the PHP 8.4 PDO-compat trait.DISABLE_WP_CRON = true— fatals persist on plain page requests, so the wp-cron spawn loopback is not the trigger.SQLITE_BUSY_TIMEOUT=10000+SQLITE_JOURNAL_MODE=WAL— no effect (reported earlier).wp core install,wp post list,wp option getall clean), which is whywp core installsucceeds and only web requests break.Happy to test any proposed fix against these two sandboxes (PHP 8.3 / 8.4).
x-rush commentedon Nov 5, 2026
Full evidence: complete
debug.logentries + raw HTTP transcript + version manifestVersion manifest
Complete
debug.log(single home-page request, unmodified)Raw HTTP transcript (same request family;
curl -v http://127.0.0.1:8092/)Full response body (1050 bytes — this is the entire page, no HTML wrapper, no rendered content)
Note the visitor-facing symptom: the page is literally the raw PHP fatal dump (appears blank/black in a browser with a dark color scheme). WP-CLI on the same database and drop-in (
wp core install,wp post list,wp option get) runs with zero errors.Both sandboxes (PHP 8.3 / 8.4) are kept alive and I can test any proposed fix immediately.
x-rush commentedon Nov 5, 2026
Resolution: not a plugin bug — root cause found (my test harness's file ownership)
Please accept my apologies for the noise — with full root-cause analysis this turns out to be a test-harness artifact, not a plugin defect.
Root cause
My sandbox flow ran
wp-clias root (defaultwordpress:cliuser override), socore installcreated the SQLite database file owned byroot:rootwith mode600. The web server runs aswww-data, which could neither read nor open that file. The storage layer failed silently at boot,dbhwas never initialized, and the firstesc_sql()call surfaced the genericCannot escape data without an active database connectionfatal — far away from the actual cause.After
chown -R www-data:www-dataon the database directory (and nothing else):debug.logacross home/article/page/wp-cron requestswp post create+ home page listing via SQLiteBoth "pristine" and "migrated" sandboxes are now fully working on 3.1.3 + WP 7.1.4.
Why it fooled me (and possibly worth addressing)
WP-CLI worked flawlessly throughout (root could always access the file), so the site looked healthy from the admin/CLI side while every web request failed. The fatal message names the symptom (escaping before an active connection) rather than the cause (storage open/permission failure), which cost significant debugging time.
Suggestion (non-blocking, UX improvement)
If
WP_SQLite_Storage::initialize()fails to open/create the database file (e.g.EACCES), throwing an explicit, actionable error at that point — e.g. "Cannot open SQLite database at : permission denied (current uid )" — would turn this debugging session from hours into minutes.This issue can be closed as not-a-bug. Thank you for the well-built plugin — 3.1.3 has been rock solid once the file permissions are correct, including a fully migrated 339-post site.
[-]PHP Fatal on every web request: Cannot escape data without an active database connection (3.1.3, WP 7.1.4, PHP 8.4)[/-][+]PHP Fatal on web requests with root-owned SQLite file (3.1.3) — [RESOLVED: testing artifact, UX suggestion inside][/+]