diff --git a/a8c-files.php b/a8c-files.php index 82e54f41c8..3f67deb7f4 100644 --- a/a8c-files.php +++ b/a8c-files.php @@ -78,7 +78,7 @@ public function __construct() { return 1073741824; // 2^30 }); - if ( defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) && true === VIP_FILESYSTEM_USE_STREAM_WRAPPER ) { + if ( ! defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) || constant( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) !== false ) { $this->init_vip_filesystem(); } diff --git a/files/class-wp-filesystem-vip.php b/files/class-wp-filesystem-vip.php index 517b9dfd0a..001866e49c 100644 --- a/files/class-wp-filesystem-vip.php +++ b/files/class-wp-filesystem-vip.php @@ -65,11 +65,11 @@ private function get_transport_for_path( $filename, $context = 'read' ) { // Uploads paths can just use PHP functions when stream wrapper is enabled. // This is because wp_upload_dir will return a vip:// path. if ( $this->is_uploads_path( $filename ) ) { - if ( defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) && true === constant( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) ) { - return $this->direct; + if ( defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) && false === constant( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) ) { + return $this->uploads; } - return $this->uploads; + return $this->direct; } elseif ( $this->is_tmp_path( $filename ) ) { return $this->direct; } elseif ( 'read' === $context ) { diff --git a/stats.php b/stats.php index a895493983..da81f7168c 100644 --- a/stats.php +++ b/stats.php @@ -49,7 +49,7 @@ function track_file_upload() { return; } - $using_streams = false; + $using_streams = true; if ( defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) ) { $using_streams = (bool) VIP_FILESYSTEM_USE_STREAM_WRAPPER; } @@ -94,7 +94,7 @@ function track_file_delete() { return; } - $using_streams = false; + $using_streams = true; if ( defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) ) { $using_streams = (bool) VIP_FILESYSTEM_USE_STREAM_WRAPPER; } diff --git a/tests/files/test-wp-filesystem-vip.php b/tests/files/test-wp-filesystem-vip.php index 62acbb4952..296181a86c 100644 --- a/tests/files/test-wp-filesystem-vip.php +++ b/tests/files/test-wp-filesystem-vip.php @@ -277,8 +277,6 @@ public function test__get_transport_for_path__read() { } public function test__get_transport_for_path__uploads_streamwrapper() { - Constant_Mocker::define( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER', true ); - $get_transport_for_path = self::get_method( 'get_transport_for_path' ); $result = $get_transport_for_path->invokeArgs( $this->filesystem, [ '/tmp/wordpress/wp-content/uploads/file.file', 'read' ] ); @@ -287,6 +285,8 @@ public function test__get_transport_for_path__uploads_streamwrapper() { } public function test__get_transport_for_path__uploads() { + // Now that streamwrapper is enabled by default, we need to define it as disabled for this test. + define( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER', false ); $get_transport_for_path = self::get_method( 'get_transport_for_path' ); $result = $get_transport_for_path->invokeArgs( $this->filesystem, [ '/tmp/wordpress/wp-content/uploads/file.file', 'write' ] ); diff --git a/wp-cli/vip-filesystem.php b/wp-cli/vip-filesystem.php index 4984f69811..a5f86a3dca 100644 --- a/wp-cli/vip-filesystem.php +++ b/wp-cli/vip-filesystem.php @@ -56,8 +56,8 @@ class VIP_Files_CLI_Command extends \WPCOM_VIP_CLI_Command { * @sypnosis [--dry-run=] [--batch=] */ public function update_filesizes( $args, $assoc_args ) { - if ( ! defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) || true !== VIP_FILESYSTEM_USE_STREAM_WRAPPER ) { - WP_CLI::error( 'This script only works when the VIP Stream Wrapper is enabled. Please add `define( \'VIP_FILESYSTEM_USE_STREAM_WRAPPER\', true );` to vip-config.php and try again.' ); + if ( defined( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) && false === constant( 'VIP_FILESYSTEM_USE_STREAM_WRAPPER' ) ) { + WP_CLI::error( 'This script only works when the VIP Stream Wrapper is enabled. If the constant \'VIP_FILESYSTEM_USE_STREAM_WRAPPER\' is defined as false, please remove it.' ); return; }