Make WordPress Core

Changeset 36370


Ignore:
Timestamp:
01/21/2016 01:21:52 AM (11 years ago)
Author:
dd32
Message:

Upgrade: Switch the locking mechanism to using static methods so that it can be accessed from other upgrade-classes.

Fixes #34878

File:
1 edited

Legend:

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

    r36349 r36370  
    757757         * @since 4.5.0
    758758         * @access public
     759         * @static
    759760         *
    760761         * @param string $lock_name       The name of this unique lock.
     
    762763         * @return bool
    763764         */
    764         public function create_lock( $lock_name, $release_timeout = null ) {
     765        public static function create_lock( $lock_name, $release_timeout = null ) {
    765766                global $wpdb;
    766767                if ( ! $release_timeout ) {
     
    786787
    787788                        // There must exist an expired lock, clear it and re-gain it.
    788                         $this->release_lock( $lock_name );
    789 
    790                         return $this->create_lock( $lock_name, $release_timeout );
     789                        WP_Upgrader::release_lock( $lock_name );
     790
     791                        return WP_Upgrader::create_lock( $lock_name, $release_timeout );
    791792                }
    792793
     
    802803         * @since 4.5.0
    803804         * @access public
     805         * @static
    804806         *
    805807         * @param string $lock_name The name of this unique lock.
    806808         * @return bool
    807809         */
    808         public function release_lock( $lock_name ) {
     810        public static function release_lock( $lock_name ) {
    809811                return delete_option( $lock_name . '.lock' );
    810812        }
     
    23132315
    23142316                // Lock to prevent multiple Core Updates occuring
    2315                 $lock = $this->create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
     2317                $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
    23162318                if ( ! $lock ) {
    23172319                        return new WP_Error( 'locked', $this->strings['locked'] );
     
    23202322                $download = $this->download_package( $current->packages->$to_download );
    23212323                if ( is_wp_error( $download ) ) {
    2322                         $this->release_lock( 'core_updater' );
     2324                        WP_Upgrader::release_lock( 'core_updater' );
    23232325                        return $download;
    23242326                }
     
    23262328                $working_dir = $this->unpack_package( $download );
    23272329                if ( is_wp_error( $working_dir ) ) {
    2328                         $this->release_lock( 'core_updater' );
     2330                        WP_Upgrader::release_lock( 'core_updater' );
    23292331                        return $working_dir;
    23302332                }
     
    23332335                if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) {
    23342336                        $wp_filesystem->delete($working_dir, true);
    2335                         $this->release_lock( 'core_updater' );
     2337                        WP_Upgrader::release_lock( 'core_updater' );
    23362338                        return new WP_Error( 'copy_failed_for_update_core_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-admin/includes/update-core.php' );
    23372339                }
     
    23412343
    23422344                if ( ! function_exists( 'update_core' ) ) {
    2343                         $this->release_lock( 'core_updater' );
     2345                        WP_Upgrader::release_lock( 'core_updater' );
    23442346                        return new WP_Error( 'copy_failed_space', $this->strings['copy_failed_space'] );
    23452347                }
     
    24182420                }
    24192421
    2420                 $this->release_lock( 'core_updater' );
     2422                WP_Upgrader::release_lock( 'core_updater' );
    24212423
    24222424                return $result;
     
    30553057                        return;
    30563058
    3057                 if ( ! $this->create_lock( 'auto_updater' ) )
     3059                if ( ! WP_Upgrader::create_lock( 'auto_updater' ) )
    30583060                        return;
    30593061
     
    31553157                }
    31563158
    3157                 $this->release_lock( 'auto_updater' );
     3159                WP_Upgrader::release_lock( 'auto_updater' );
    31583160        }
    31593161
Note: See TracChangeset for help on using the changeset viewer.