diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index f3764cb470..f23afac790 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -498,7 +498,7 @@ function unzip_file($file, $to) { if ( $fs->is_dir($tmppath) ) { //Found the highest folder that exists, Create from here(ie +1) for ( $i = $i + 1; $i <= count($path); $i++ ) { $tmppath = implode('/', array_slice($path, 0, $i) ); - if ( ! $fs->mkdir($tmppath, 0755) ) + if ( ! $fs->mkdir($tmppath, FS_CHMOD_DIR) ) return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); } break; //Exit main for loop @@ -516,7 +516,7 @@ function unzip_file($file, $to) { if ( $fs->is_dir($tmppath) ) {//Found the highest folder that exists, Create from here for ( $i = $i + 1; $i <= count($path); $i++ ) { //< count() no file component please. $tmppath = $to . implode('/', array_slice($path, 0, $i) ); - if ( ! $fs->is_dir($tmppath) && ! $fs->mkdir($tmppath, 0755) ) + if ( ! $fs->is_dir($tmppath) && ! $fs->mkdir($tmppath, FS_CHMOD_DIR) ) return new WP_Error('mkdir_failed', __('Could not create directory'), $tmppath); } break; //Exit main for loop @@ -527,7 +527,7 @@ function unzip_file($file, $to) { if ( ! $file['folder'] ) { if ( !$fs->put_contents( $to . $file['filename'], $file['content']) ) return new WP_Error('copy_failed', __('Could not copy file'), $to . $file['filename']); - $fs->chmod($to . $file['filename'], 0644); + $fs->chmod($to . $file['filename'], FS_CHMOD_FILE); } } return true; @@ -558,10 +558,10 @@ function copy_dir($from, $to) { if ( ! $wp_filesystem->copy($from . $filename, $to . $filename, true) ) return new WP_Error('copy_failed', __('Could not copy file'), $to . $filename); } - $wp_filesystem->chmod($to . $filename, 0644); + $wp_filesystem->chmod($to . $filename, FS_CHMOD_FILE); } elseif ( 'd' == $fileinfo['type'] ) { if ( !$wp_filesystem->is_dir($to . $filename) ) { - if ( !$wp_filesystem->mkdir($to . $filename, 0755) ) + if ( !$wp_filesystem->mkdir($to . $filename, FS_CHMOD_DIR) ) return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename); } $result = copy_dir($from . $filename, $to . $filename); @@ -604,6 +604,12 @@ function WP_Filesystem( $args = false ) { if ( !$wp_filesystem->connect() ) return false; //There was an erorr connecting to the server. + // Set the permission constants if not already set. + if ( ! defined('FS_CHMOD_DIR') ) + define('FS_CHMOD_DIR', 0755 ); + if ( ! defined('FS_CHMOD_FILE') ) + define('FS_CHMOD_FILE', 0644 ); + return true; } diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index de8a85199c..2e4781b2fe 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -227,7 +227,7 @@ function update_core($from, $to) { $maintenance_string = ''; $maintenance_file = $to . '.maintenance'; $wp_filesystem->delete($maintenance_file); - $wp_filesystem->put_contents($maintenance_file, $maintenance_string, 0644); + $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE); // Copy new versions of WP files into place. $result = copy_dir($from . '/wordpress', $to); diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index ef4128da8b..df5e3cd0bc 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -468,7 +468,7 @@ function wp_update_core($current, $feedback = '') { $wp_filesystem->delete($working_dir, true); return new WP_Error('copy_failed', __('Could not copy files')); } - $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', 0644); + $wp_filesystem->chmod($wp_dir . 'wp-admin/includes/update-core.php', FS_CHMOD_FILE); require(ABSPATH . 'wp-admin/includes/update-core.php');