Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make (Local) Core Upgrades Work Again #1185

Merged
merged 2 commits into from
Apr 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions files/class-wp-filesystem-vip.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ public function __construct( $dependencies ) {
* @return WP_Filesystem_VIP_Uploads|bool|mixed|WP_Filesystem_Direct
*/
private function get_transport_for_path( $filename, $context = 'read' ) {
// If we're not in a VIP environment, allow core upgrades to work.
// Note: WP_CLI doesn't set WP_INSTALLING so we fallback to checking for the upgrade lock instead.
if ( true !== VIP_GO_ENV &&
( wp_installing() || get_option( 'core_updater.lock' ) ) ) {
return $this->direct;
}

// 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 ) ) {
Expand All @@ -56,8 +63,11 @@ private function get_transport_for_path( $filename, $context = 'read' ) {
return $this->direct;
}

/* Translators: 1) file name 2) class name */
$error_msg = sprintf( __( 'The `%1$s` file cannot be managed by the `%2$s` class. Writes are only allowed for the `/uploads` and `/tmp` directories and reads can be performed everywhere.' ), $filename, __CLASS__ );
$upload_dir = wp_get_upload_dir()['basedir'];
$temp_dir = get_temp_dir();

/* Translators: 1) file name 2) class name 3) tmp dir path 4) uploads dir path */
$error_msg = sprintf( __( 'The `%1$s` file cannot be managed by the `%2$s` class. Writes are only allowed for the `%3$s` and `%4$s` directories and reads can be performed everywhere.' ), $filename, __CLASS__, $temp_dir, $upload_dir );

$this->errors->add( 'unsupported-filepath', $error_msg );

Expand Down