@@ -690,7 +690,7 @@ private static function configure_sqlite( $dir ): void {
690690 private static function cache_wp_files ( $ version = '' ): void {
691691 $ wp_version = $ version ?: getenv ( 'WP_VERSION ' );
692692 $ wp_version_suffix = $ wp_version ? "- $ wp_version " : '' ;
693- self :: $ cache_dir = sys_get_temp_dir () . '/wp-cli-test-core-download-cache ' . $ wp_version_suffix ;
693+ $ cache_dir = sys_get_temp_dir () . '/wp-cli-test-core-download-cache ' . $ wp_version_suffix ;
694694 self ::$ sqlite_cache_dir = sys_get_temp_dir () . '/wp-cli-test-sqlite-integration-cache ' ;
695695
696696 if ( 'sqlite ' === getenv ( 'WP_CLI_TEST_DBTYPE ' ) ) {
@@ -706,15 +706,34 @@ private static function cache_wp_files( $version = '' ): void {
706706 }
707707 }
708708
709- if ( is_readable ( self ::$ cache_dir . '/wp-config-sample.php ' ) ) {
709+ if ( is_readable ( $ cache_dir . '/wp-includes/version.php ' ) ) {
710+ self ::$ cache_dir = $ cache_dir ;
710711 return ;
711712 }
712713
713- $ cmd = Utils \esc_cmd ( 'wp core download --force --path=%s ' , self :: $ cache_dir );
714+ $ cmd = Utils \esc_cmd ( 'wp core download --force --path=%s ' , $ cache_dir );
714715 if ( $ wp_version ) {
715716 $ cmd .= Utils \esc_cmd ( ' --version=%s ' , $ wp_version );
716717 }
717- Process::create ( $ cmd , null , self ::get_process_env_variables () )->run_check ();
718+
719+ $ max_retries = 3 ;
720+ $ retry_count = 0 ;
721+ $ completed = false ;
722+
723+ // This is in addition to the retry logic inside Utils\http_request().
724+ while ( $ retry_count < $ max_retries && ! $ completed ) {
725+ try {
726+ Process::create ( $ cmd , null , self ::get_process_env_variables () )->run_check ();
727+ $ completed = true ;
728+ } catch ( \Exception $ e ) {
729+ ++$ retry_count ;
730+ if ( $ retry_count >= $ max_retries ) {
731+ throw $ e ;
732+ }
733+ }
734+ }
735+
736+ self ::$ cache_dir = $ cache_dir ;
718737 }
719738
720739 /**
@@ -1533,7 +1552,7 @@ public static function copy_dir( $src_dir, $dest_dir ): void {
15331552 * @var \SplFileInfo $item
15341553 */
15351554 foreach ( $ iterator as $ item ) {
1536- $ dest_path = $ dest_dir . ' / ' . $ iterator ->getSubPathname ();
1555+ $ dest_path = rtrim ( $ dest_dir, ' / \\' ) . DIRECTORY_SEPARATOR . $ iterator ->getSubPathname ();
15371556 if ( $ item ->isDir () ) {
15381557 if ( ! is_dir ( $ dest_path ) ) {
15391558 mkdir ( $ dest_path , 0777 , true );
@@ -1573,7 +1592,7 @@ public function download_wp( $subdir = '', $version = '' ): void {
15731592 echo "WordPress {$ result ->stdout }\n" ;
15741593 }
15751594
1576- $ dest_dir = $ this ->variables ['RUN_DIR ' ] . " / $ subdir" ;
1595+ $ dest_dir = rtrim ( $ this ->variables ['RUN_DIR ' ], ' / \\' ) . ( $ subdir ? DIRECTORY_SEPARATOR . $ subdir : '' ) ;
15771596
15781597 if ( $ subdir ) {
15791598 mkdir ( $ dest_dir , 0777 , true /*recursive*/ );
0 commit comments