@@ -1953,50 +1953,11 @@ public function install_wp( $subdir = '', $version = '' ): void {
19531953
19541954 $ install_cache_path = self ::$ install_cache_dir . '/install_ ' . md5 ( implode ( ': ' , $ install_args ) . ':subdir= ' . $ subdir . ':object_cache= ' . getenv ( 'WP_CLI_TEST_OBJECT_CACHE ' ) );
19551955
1956- $ install_cache_is_valid = is_dir ( $ install_cache_path )
1957- && ( 'sqlite ' !== self ::$ db_type || file_exists ( "{$ install_cache_path }.sqlite " ) );
1958-
1959- if ( ! $ install_cache_is_valid && file_exists ( $ install_cache_path ) ) {
1960- if ( is_dir ( $ install_cache_path ) ) {
1961- $ iterator = new \RecursiveIteratorIterator (
1962- new \RecursiveDirectoryIterator ( $ install_cache_path , \FilesystemIterator::SKIP_DOTS ),
1963- \RecursiveIteratorIterator::CHILD_FIRST
1964- );
1965- foreach ( $ iterator as $ fileinfo ) {
1966- if ( $ fileinfo ->isDir () ) {
1967- rmdir ( $ fileinfo ->getPathname () );
1968- } else {
1969- unlink ( $ fileinfo ->getPathname () );
1970- }
1971- }
1972- rmdir ( $ install_cache_path );
1973- } else {
1974- unlink ( $ install_cache_path );
1975- }
1976-
1977- $ sqlite_cache = "{$ install_cache_path }.sqlite " ;
1978- if ( file_exists ( $ sqlite_cache ) && is_file ( $ sqlite_cache ) ) {
1979- unlink ( $ sqlite_cache );
1980- }
1981-
1982- $ sql_cache = "{$ install_cache_path }.sql " ;
1983- if ( file_exists ( $ sql_cache ) && is_file ( $ sql_cache ) ) {
1984- unlink ( $ sql_cache );
1985- }
1986- }
1987- if ( $ install_cache_is_valid ) {
1956+ // The cache includes the SQLite database, stored under "wp-content/database".
1957+ if ( is_dir ( $ install_cache_path ) ) {
19881958 self ::copy_dir ( $ install_cache_path , $ run_dir );
19891959
1990- // This is the sqlite equivalent of restoring a database dump in MySQL
1991- if ( 'sqlite ' === self ::$ db_type ) {
1992- $ sqlite_dest_dir = "$ run_dir/wp-content/database " ;
1993- if ( ! is_dir ( $ sqlite_dest_dir ) ) {
1994- mkdir ( $ sqlite_dest_dir , 0755 , true );
1995- }
1996- if ( file_exists ( "{$ install_cache_path }.sqlite " ) ) {
1997- copy ( "{$ install_cache_path }.sqlite " , "$ sqlite_dest_dir/.ht.sqlite.php " );
1998- }
1999- } else {
1960+ if ( 'sqlite ' !== self ::$ db_type ) {
20001961 $ ssl_flag = 'mariadb ' === self ::$ db_type ? ' --skip-ssl-verify-server-cert ' : '' ;
20011962 self ::run_sql ( self ::$ mysql_binary . ' --no-defaults ' . $ ssl_flag , [ 'execute ' => "source {$ install_cache_path }.sql " ], true /*add_database*/ );
20021963 }
@@ -2021,21 +1982,6 @@ public function install_wp( $subdir = '', $version = '' ): void {
20211982 }
20221983 self ::run_sql ( $ command , [ 'result-file ' => "{$ install_cache_path }.sql " ], true /*add_database*/ );
20231984 }
2024-
2025- if ( 'sqlite ' === self ::$ db_type ) {
2026- // This is the sqlite equivalent of creating a database dump in MySQL
2027- // Support both the new (.ht.sqlite.php) and legacy (.ht.sqlite) file names.
2028- $ sqlite_source = "$ run_dir/wp-content/database/.ht.sqlite.php " ;
2029- if ( ! file_exists ( $ sqlite_source ) ) {
2030- $ sqlite_source = "$ run_dir/wp-content/database/.ht.sqlite " ;
2031- }
2032- if ( file_exists ( $ sqlite_source ) ) {
2033- copy ( $ sqlite_source , "{$ install_cache_path }.sqlite " );
2034- } elseif ( file_exists ( "{$ install_cache_path }.sqlite " ) ) {
2035- // Ensure we don't keep a stale cached SQLite DB if the source wasn't produced
2036- unlink ( "{$ install_cache_path }.sqlite " );
2037- }
2038- }
20391985 }
20401986 }
20411987
0 commit comments