From 78537bb9c9d7ae771a9ebd97068bd2c1a3be48f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jake=C5=A1?= Date: Wed, 25 Mar 2026 17:42:23 +0100 Subject: [PATCH] Migrate database file from a possible legacy path --- wp-includes/sqlite/class-wp-sqlite-db.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/wp-includes/sqlite/class-wp-sqlite-db.php b/wp-includes/sqlite/class-wp-sqlite-db.php index 0af6ac70..c0ee2bbc 100644 --- a/wp-includes/sqlite/class-wp-sqlite-db.php +++ b/wp-includes/sqlite/class-wp-sqlite-db.php @@ -306,6 +306,26 @@ public function db_connect( $allow_bail = true ) { if ( isset( $GLOBALS['@pdo'] ) ) { $pdo = $GLOBALS['@pdo']; } + + // Migrate the database file from a legacy path, if it exists. + if ( ! defined( 'DB_FILE' ) && ! file_exists( FQDB ) ) { + $old_db_path = FQDBDIR . '.ht.sqlite.php'; + + if ( file_exists( $old_db_path ) ) { + if ( ! rename( $old_db_path, FQDB ) ) { + wp_die( 'Failed to rename database file.', 'Error!' ); + } + + foreach ( array( '-wal', '-shm', '-journal' ) as $suffix ) { + if ( file_exists( $old_db_path . $suffix ) ) { + if ( ! rename( $old_db_path . $suffix, FQDB . $suffix ) ) { + wp_die( 'Failed to rename database file.', 'Error!' ); + } + } + } + } + } + if ( defined( 'WP_SQLITE_AST_DRIVER' ) && WP_SQLITE_AST_DRIVER ) { if ( null === $this->dbname || '' === $this->dbname ) { $this->bail(