File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -306,6 +306,26 @@ public function db_connect( $allow_bail = true ) {
306306 if ( isset ( $ GLOBALS ['@pdo ' ] ) ) {
307307 $ pdo = $ GLOBALS ['@pdo ' ];
308308 }
309+
310+ // Migrate the database file from a legacy path, if it exists.
311+ if ( ! defined ( 'DB_FILE ' ) && ! file_exists ( FQDB ) ) {
312+ $ old_db_path = FQDBDIR . '.ht.sqlite.php ' ;
313+
314+ if ( file_exists ( $ old_db_path ) ) {
315+ if ( ! rename ( $ old_db_path , FQDB ) ) {
316+ wp_die ( 'Failed to rename database file. ' , 'Error! ' );
317+ }
318+
319+ foreach ( array ( '-wal ' , '-shm ' , '-journal ' ) as $ suffix ) {
320+ if ( file_exists ( $ old_db_path . $ suffix ) ) {
321+ if ( ! rename ( $ old_db_path . $ suffix , FQDB . $ suffix ) ) {
322+ wp_die ( 'Failed to rename database file. ' , 'Error! ' );
323+ }
324+ }
325+ }
326+ }
327+ }
328+
309329 if ( defined ( 'WP_SQLITE_AST_DRIVER ' ) && WP_SQLITE_AST_DRIVER ) {
310330 if ( null === $ this ->dbname || '' === $ this ->dbname ) {
311331 $ this ->bail (
You can’t perform that action at this time.
0 commit comments