2424use WP_CLI \Process ;
2525use WP_CLI \ProcessRun ;
2626use WP_CLI \Utils ;
27+ use WP_CLI \Path ;
2728use WP_CLI \WpOrgApi ;
2829
2930/**
@@ -1650,7 +1651,13 @@ public function install_wp( $subdir = '', $version = '' ): void {
16501651
16511652 // This is the sqlite equivalent of restoring a database dump in MySQL
16521653 if ( 'sqlite ' === self ::$ db_type ) {
1653- copy ( "{$ install_cache_path }.sqlite " , "$ run_dir/wp-content/database/.ht.sqlite " );
1654+ $ sqlite_dest_dir = "$ run_dir/wp-content/database " ;
1655+ if ( ! is_dir ( $ sqlite_dest_dir ) ) {
1656+ mkdir ( $ sqlite_dest_dir , 0755 , true );
1657+ }
1658+ if ( file_exists ( "{$ install_cache_path }.sqlite " ) ) {
1659+ copy ( "{$ install_cache_path }.sqlite " , "$ sqlite_dest_dir/.ht.sqlite.php " );
1660+ }
16541661 } else {
16551662 $ ssl_flag = 'mariadb ' === self ::$ db_type ? ' --ssl-verify-server-cert ' : '' ;
16561663 self ::run_sql ( self ::$ mysql_binary . ' --no-defaults ' . $ ssl_flag , [ 'execute ' => "source {$ install_cache_path }.sql " ], true /*add_database*/ );
@@ -1679,7 +1686,11 @@ public function install_wp( $subdir = '', $version = '' ): void {
16791686
16801687 if ( 'sqlite ' === self ::$ db_type ) {
16811688 // This is the sqlite equivalent of creating a database dump in MySQL
1682- $ sqlite_source = "$ run_dir/wp-content/database/.ht.sqlite " ;
1689+ // Support both the new (.ht.sqlite.php) and legacy (.ht.sqlite) file names.
1690+ $ sqlite_source = "$ run_dir/wp-content/database/.ht.sqlite.php " ;
1691+ if ( ! file_exists ( $ sqlite_source ) ) {
1692+ $ sqlite_source = "$ run_dir/wp-content/database/.ht.sqlite " ;
1693+ }
16831694 if ( file_exists ( $ sqlite_source ) ) {
16841695 copy ( $ sqlite_source , "{$ install_cache_path }.sqlite " );
16851696 } elseif ( file_exists ( "{$ install_cache_path }.sqlite " ) ) {
@@ -1901,8 +1912,8 @@ private static function get_scenario_key( $scope ): string {
19011912 $ scenario_key = '' ;
19021913 $ file = self ::get_event_file ( $ scope , $ line );
19031914 if ( isset ( $ file ) ) {
1904- $ scenario_grandparent = Utils \ basename ( dirname ( $ file , 2 ) );
1905- $ scenario_key = $ scenario_grandparent . ' ' . Utils \ basename ( $ file ) . ': ' . $ line ;
1915+ $ scenario_grandparent = Path:: basename ( dirname ( $ file , 2 ) );
1916+ $ scenario_key = $ scenario_grandparent . ' ' . Path:: basename ( $ file ) . ': ' . $ line ;
19061917 }
19071918 return $ scenario_key ;
19081919 }
@@ -1919,7 +1930,7 @@ private static function log_run_times_after_suite( AfterSuiteScope $scope ): voi
19191930 $ suite = substr ( $ keys [0 ], 0 , strpos ( $ keys [0 ], ' ' ) );
19201931 }
19211932
1922- $ run_from = Utils \ basename ( dirname ( __DIR__ , 2 ) );
1933+ $ run_from = Path:: basename ( dirname ( __DIR__ , 2 ) );
19231934
19241935 // Format same as Behat, if have minutes.
19251936 $ fmt = static function ( $ time ) {
0 commit comments