equal
deleted
inserted
replaced
202 $this->strings['no_files'] = __( 'The package contains no files.' ); |
202 $this->strings['no_files'] = __( 'The package contains no files.' ); |
203 $this->strings['folder_exists'] = __( 'Destination folder already exists.' ); |
203 $this->strings['folder_exists'] = __( 'Destination folder already exists.' ); |
204 $this->strings['mkdir_failed'] = __( 'Could not create directory.' ); |
204 $this->strings['mkdir_failed'] = __( 'Could not create directory.' ); |
205 $this->strings['incompatible_archive'] = __( 'The package could not be installed.' ); |
205 $this->strings['incompatible_archive'] = __( 'The package could not be installed.' ); |
206 $this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ); |
206 $this->strings['files_not_writable'] = __( 'The update cannot be installed because some files could not be copied. This is usually due to inconsistent file permissions.' ); |
|
207 $this->strings['dir_not_readable'] = __( 'A directory could not be read.' ); |
207 |
208 |
208 $this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' ); |
209 $this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' ); |
209 $this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' ); |
210 $this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' ); |
210 |
211 |
211 /* translators: %s: upgrade-temp-backup */ |
212 /* translators: %s: upgrade-temp-backup */ |
483 * |
484 * |
484 * @since 2.8.0 |
485 * @since 2.8.0 |
485 * @since 6.2.0 Use move_dir() instead of copy_dir() when possible. |
486 * @since 6.2.0 Use move_dir() instead of copy_dir() when possible. |
486 * |
487 * |
487 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. |
488 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. |
488 * @global array $wp_theme_directories |
489 * @global string[] $wp_theme_directories |
489 * |
490 * |
490 * @param array|string $args { |
491 * @param array|string $args { |
491 * Optional. Array or string of arguments for installing a package. Default empty array. |
492 * Optional. Array or string of arguments for installing a package. Default empty array. |
492 * |
493 * |
493 * @type string $source Required path to the package source. Default empty. |
494 * @type string $source Required path to the package source. Default empty. |
522 // These were previously extract()'d. |
523 // These were previously extract()'d. |
523 $source = $args['source']; |
524 $source = $args['source']; |
524 $destination = $args['destination']; |
525 $destination = $args['destination']; |
525 $clear_destination = $args['clear_destination']; |
526 $clear_destination = $args['clear_destination']; |
526 |
527 |
|
528 /* |
|
529 * Give the upgrade an additional 300 seconds (5 minutes) to ensure the install |
|
530 * doesn't prematurely timeout having used up the maximum script execution time |
|
531 * upacking and downloading in WP_Upgrader->run(). |
|
532 */ |
527 if ( function_exists( 'set_time_limit' ) ) { |
533 if ( function_exists( 'set_time_limit' ) ) { |
528 set_time_limit( 300 ); |
534 set_time_limit( 300 ); |
529 } |
535 } |
530 |
536 |
531 if ( |
537 if ( |
555 |
561 |
556 // Retain the original source and destinations. |
562 // Retain the original source and destinations. |
557 $remote_source = $args['source']; |
563 $remote_source = $args['source']; |
558 $local_destination = $destination; |
564 $local_destination = $destination; |
559 |
565 |
560 $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); |
566 $dirlist = $wp_filesystem->dirlist( $remote_source ); |
|
567 |
|
568 if ( false === $dirlist ) { |
|
569 return new WP_Error( 'source_read_failed', $this->strings['fs_error'], $this->strings['dir_not_readable'] ); |
|
570 } |
|
571 |
|
572 $source_files = array_keys( $dirlist ); |
561 $remote_destination = $wp_filesystem->find_folder( $local_destination ); |
573 $remote_destination = $wp_filesystem->find_folder( $local_destination ); |
562 |
574 |
563 // Locate which directory to copy to the new folder. This is based on the actual folder holding the files. |
575 // Locate which directory to copy to the new folder. This is based on the actual folder holding the files. |
564 if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { |
576 if ( 1 === count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { |
565 // Only one folder? Then we want its contents. |
577 // Only one folder? Then we want its contents. |
602 $this->temp_backups[] = $args['hook_extra']['temp_backup']; |
614 $this->temp_backups[] = $args['hook_extra']['temp_backup']; |
603 } |
615 } |
604 |
616 |
605 // Has the source location changed? If so, we need a new source_files list. |
617 // Has the source location changed? If so, we need a new source_files list. |
606 if ( $source !== $remote_source ) { |
618 if ( $source !== $remote_source ) { |
607 $source_files = array_keys( $wp_filesystem->dirlist( $source ) ); |
619 $dirlist = $wp_filesystem->dirlist( $source ); |
|
620 |
|
621 if ( false === $dirlist ) { |
|
622 return new WP_Error( 'new_source_read_failed', $this->strings['fs_error'], $this->strings['dir_not_readable'] ); |
|
623 } |
|
624 |
|
625 $source_files = array_keys( $dirlist ); |
608 } |
626 } |
609 |
627 |
610 /* |
628 /* |
611 * Protection against deleting files in any important base directories. |
629 * Protection against deleting files in any important base directories. |
612 * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the |
630 * Theme_Upgrader & Plugin_Upgrader also trigger this, as they pass the |
988 */ |
1006 */ |
989 public function maintenance_mode( $enable = false ) { |
1007 public function maintenance_mode( $enable = false ) { |
990 global $wp_filesystem; |
1008 global $wp_filesystem; |
991 |
1009 |
992 if ( ! $wp_filesystem ) { |
1010 if ( ! $wp_filesystem ) { |
993 require_once ABSPATH . 'wp-admin/includes/file.php'; |
1011 if ( ! function_exists( 'WP_Filesystem' ) ) { |
994 WP_Filesystem(); |
1012 require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
1013 } |
|
1014 |
|
1015 ob_start(); |
|
1016 $credentials = request_filesystem_credentials( '' ); |
|
1017 ob_end_clean(); |
|
1018 |
|
1019 if ( false === $credentials || ! WP_Filesystem( $credentials ) ) { |
|
1020 wp_trigger_error( __FUNCTION__, __( 'Could not access filesystem.' ) ); |
|
1021 return; |
|
1022 } |
995 } |
1023 } |
996 |
1024 |
997 $file = $wp_filesystem->abspath() . '.maintenance'; |
1025 $file = $wp_filesystem->abspath() . '.maintenance'; |
998 if ( $enable ) { |
1026 if ( $enable ) { |
999 if ( ! wp_doing_cron() ) { |
1027 if ( ! wp_doing_cron() ) { |
1051 |
1079 |
1052 return WP_Upgrader::create_lock( $lock_name, $release_timeout ); |
1080 return WP_Upgrader::create_lock( $lock_name, $release_timeout ); |
1053 } |
1081 } |
1054 |
1082 |
1055 // Update the lock, as by this point we've definitely got a lock, just need to fire the actions. |
1083 // Update the lock, as by this point we've definitely got a lock, just need to fire the actions. |
1056 update_option( $lock_option, time() ); |
1084 update_option( $lock_option, time(), false ); |
1057 |
1085 |
1058 return true; |
1086 return true; |
1059 } |
1087 } |
1060 |
1088 |
1061 /** |
1089 /** |