Make WordPress Core


Ignore:
Timestamp:
11/19/2014 05:39:52 AM (12 years ago)
Author:
dd32
Message:

Background Updates: Introduce support to take advantage of Group Writable (or World Writable) to Core Background updates.
This is only enabled when new files will not be installed during the update (as indicated by the WordPress.org API), and does not apply to Plugin/Theme/Translation Background Updates.

Additionally, the code to determine if the 'direct' filesystem transport should be used has been tweaked for wider support (where getmyuid() was unavailalbe) which fixes #10424

See #10205, #30245

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-upgrader.php

    r30171 r30384  
    6262        }
    6363
    64         public function fs_connect( $directories = array() ) {
     64        public function fs_connect( $directories = array(), $allow_relaxed_file_ownership = false ) {
    6565                global $wp_filesystem;
    6666
    67                 if ( false === ($credentials = $this->skin->request_filesystem_credentials()) )
     67                if ( false === ( $credentials = $this->skin->request_filesystem_credentials( false, $directories[0], $allow_relaxed_file_ownership ) ) ) {
    6868                        return false;
    69 
    70                 if ( ! WP_Filesystem($credentials) ) {
     69                }
     70
     71                if ( ! WP_Filesystem( $credentials, $directories[0], $allow_relaxed_file_ownership ) ) {
    7172                        $error = true;
    7273                        if ( is_object($wp_filesystem) && $wp_filesystem->errors->get_error_code() )
    7374                                $error = $wp_filesystem->errors;
    74                         $this->skin->request_filesystem_credentials($error); //Failed to connect, Error and request again
     75                        // Failed to connect, Error and request again
     76                        $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership );
    7577                        return false;
    7678                }
    … …  
    14571459                        'attempt_rollback' => false,
    14581460                        'do_rollback'      => false,
     1461                        'allow_relaxed_file_ownership' => false,
    14591462                );
    14601463                $parsed_args = wp_parse_args( $args, $defaults );
    … …  
    14671470                        return new WP_Error('up_to_date', $this->strings['up_to_date']);
    14681471
    1469                 $res = $this->fs_connect( array(ABSPATH, WP_CONTENT_DIR) );
     1472                $res = $this->fs_connect( array( ABSPATH, WP_CONTENT_DIR ), $parsed_args['allow_relaxed_file_ownership'] );
    14701473                if ( ! $res || is_wp_error( $res ) ) {
    14711474                        return $res;
    … …  
    19121915                        return false;
    19131916
     1917                // Only relax the filesystem checks when the update doesn't include new files
     1918                $allow_relaxed_file_ownership = false;
     1919                if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) {
     1920                        $allow_relaxed_file_ownership = true;
     1921                }
     1922
    19141923                // If we can't do an auto core update, we may still be able to email the user.
    1915                 if ( ! $skin->request_filesystem_credentials( false, $context ) || $this->is_vcs_checkout( $context ) ) {
     1924                if ( ! $skin->request_filesystem_credentials( false, $context, $allow_relaxed_file_ownership ) || $this->is_vcs_checkout( $context ) ) {
    19161925                        if ( 'core' == $type )
    19171926                                $this->send_core_update_notification_email( $item );
    … …  
    20732082                }
    20742083
     2084                $allow_relaxed_file_ownership = false;
     2085                if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) {
     2086                        $allow_relaxed_file_ownership = true;
     2087                }
     2088
    20752089                // Boom, This sites about to get a whole new splash of paint!
    20762090                $upgrade_result = $upgrader->upgrade( $upgrader_item, array(
    … …  
    20802094                        // Only available for core updates.
    20812095                        'attempt_rollback'   => true,
     2096                        // Allow relaxed file ownership in some scenarios
     2097                        'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
     2098                       
    20822099                ) );
    20832100
Note: See TracChangeset for help on using the changeset viewer.