Ticket #5560: 5560.2.diff
| File 5560.2.diff, 9.3 KB (added by ryan, 5 years ago) |
|---|
-
wp-settings.php
107 107 if ( !defined('WP_CONTENT_DIR') ) 108 108 define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down 109 109 110 if ( file_exists(ABSPATH . '.maintenance') ) { 111 if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) { 112 require_once( WP_CONTENT_DIR . '/maintenance.php' ); 113 die(); 114 } 115 116 $protocol = $_SERVER["SERVER_PROTOCOL"]; 117 if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) 118 $protocol = 'HTTP/1.0'; 119 header( "$protocol 503 Service Unavailable", true, 503 ); 120 header( 'Content-Type: text/html; charset=utf-8' ); 121 ?> 122 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 123 <html xmlns="http://www.w3.org/1999/xhtml"> 124 <head> 125 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 126 <title>Maintenance</title> 127 128 </head> 129 <body> 130 <h1>Briefly unavailable for scheduled maintenance. Check back in a minute.</h1> 131 </body> 132 </html> 133 <?php 134 die(); 135 } 136 110 137 if ( !extension_loaded('mysql') && !file_exists(WP_CONTENT_DIR . '/db.php') ) 111 138 die( /*WP_I18N_OLD_MYSQL*/'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.'/*/WP_I18N_OLD_MYSQL*/ ); 112 139 -
wp-admin/includes/update-core.php
1 <?php 2 3 function update_core($from, $to) { 4 global $wp_filesystem; 5 6 // Sanity check the unzipped distribution 7 apply_filters('update_feedback', __('Verifying the unpacked files')); 8 if ( !file_exists($from . '/wordpress/wp-settings.php') || !file_exists($from . '/wordpress/wp-admin/admin.php') || 9 !file_exists($from . '/wordpress/wp-includes/functions.php') ) { 10 $wp_filesystem->delete($from, true); 11 return new WP_Error('insane_distro', __('The update could not be unpacked') ); 12 } 13 14 apply_filters('update_feedback', __('Installing the latest version')); 15 16 // Create maintenance file to signal that we are upgrading 17 $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; 18 $maintenance_file = $to . '.maintenance'; 19 $wp_filesystem->delete($maintenance_file); 20 $wp_filesystem->put_contents($maintenance_file, $maintenance_string, 0644); 21 22 // Copy new versions of WP files into place. 23 $result = copy_dir($from . '/wordpress', $to); 24 if ( is_wp_error($result) ) { 25 $wp_filesystem->delete($maintenance_file); 26 //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails. 27 return $result; 28 } 29 30 // Might have to do upgrade in a separate step. 31 apply_filters('update_feedback', __('Upgrading database')); 32 // Get new db version 33 global $wp_db_version; 34 require (ABSPATH . WPINC . '/version.php'); 35 // Upgrade db 36 define('WP_INSTALLING', true); 37 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 38 wp_upgrade(); 39 40 // Remove working directory 41 $wp_filesystem->delete($from, true); 42 43 // Remove maintenance file, we're done. 44 $wp_filesystem->delete($maintenance_file); 45 46 // Force refresh of update information 47 delete_option('update_core'); 48 } 49 50 ?> 51 No newline at end of file -
wp-admin/includes/file.php
Property changes on: wp-admin/includes/update-core.php ___________________________________________________________________ Name: svn:eol-style + native
408 408 return new WP_Error('copy_failed', __('Could not copy file'), $to . $filename); 409 409 $wp_filesystem->chmod($to . $filename, 0644); 410 410 } elseif ( 'd' == $fileinfo['type'] ) { 411 if ( !$wp_filesystem->mkdir($to . $filename, 0755) ) 412 return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename); 411 if ( !$wp_filesystem->is_dir($to . $filename) ) { 412 if ( !$wp_filesystem->mkdir($to . $filename, 0755) ) 413 return new WP_Error('mkdir_failed', __('Could not create directory'), $to . $filename); 414 } 413 415 $result = copy_dir($from . $filename, $to . $filename); 414 416 if ( is_wp_error($result) ) 415 417 return $result; -
wp-admin/includes/update.php
15 15 16 16 case 'upgrade' : 17 17 if ( current_user_can('manage_options') ) { 18 return sprintf( '| <strong>'.__( '<a href="% 2$s">Get Version %3$s</a>' ).'</strong>', $GLOBALS['wp_version'], $cur->url, $cur->current);18 return sprintf( '| <strong>'.__( '<a href="%1$s">Get Version %2$s</a>' ).'</strong>', wp_nonce_url('update.php?action=upgrade-core', 'upgrade-core'), $cur->current); 19 19 break; 20 20 } 21 21 … … 188 188 return $folder . '/' . $pluginfiles[0]; 189 189 } 190 190 191 function wp_update_core($feedback = '') { 192 global $wp_filesystem; 193 194 if ( !empty($feedback) ) 195 add_filter('update_feedback', $feedback); 196 197 // Is an update available? 198 $current = get_option( 'update_core' ); 199 //if ( !isset( $current->response ) || $current->response != 'upgrade' ) 200 // return new WP_Error('up_to_date', __('WordPress is at the latest version.')); 201 202 // Is a filesystem accessor setup? 203 if ( ! $wp_filesystem || ! is_object($wp_filesystem) ) 204 WP_Filesystem(); 205 206 if ( ! is_object($wp_filesystem) ) 207 return new WP_Error('fs_unavailable', __('Could not access filesystem.')); 208 209 if ( $wp_filesystem->errors->get_error_code() ) 210 return new WP_Error('fs_error', __('Filesystem error'), $wp_filesystem->errors); 211 212 // Get the base WP folder 213 $wp_dir = $wp_filesystem->abspath(); 214 if ( empty($wp_dir) ) 215 return new WP_Error('fs_no_wp_dir', __('Unable to locate WordPress directory.')); 216 217 // And the same for the Content directory. 218 $content_dir = $wp_filesystem->wp_content_dir(); 219 if( empty($content_dir) ) 220 return new WP_Error('fs_no_content_dir', __('Unable to locate WordPress Content directory (wp-content).')); 221 222 $wp_dir = trailingslashit( $wp_dir ); 223 $content_dir = trailingslashit( $content_dir ); 224 225 // Get the URL to the zip file 226 //$package = "http://wordpress.org/wordpress-{$current->current}.zip"; 227 //$package = "http://wordpress.org/wordpress-2.6.zip"; 228 $package = "http://localhost/wordpress.zip"; 229 230 // Download the package 231 apply_filters('update_feedback', sprintf(__('Downloading update from %s'), $package)); 232 $download_file = download_url($package); 233 234 if ( is_wp_error($download_file) ) 235 return new WP_Error('download_failed', __('Download failed.'), $download_file->get_error_message()); 236 237 $working_dir = $content_dir . 'upgrade/core'; 238 239 // Clean up working directory 240 if ( $wp_filesystem->is_dir($working_dir) ) 241 $wp_filesystem->delete($working_dir, true); 242 243 apply_filters('update_feedback', __('Unpacking the update')); 244 // Unzip package to working directory 245 $result = unzip_file($download_file, $working_dir); 246 247 // Once extracted, delete the package 248 unlink($download_file); 249 250 if ( is_wp_error($result) ) { 251 $wp_filesystem->delete($working_dir, true); 252 return $result; 253 } 254 255 // Copy update-core.php from the new version into place. 256 /* if ( !$wp_filesystem->copy($working_dir . '/wordpress/wp-admin/includes/update-core.php', $wp_dir . 'wp-admin/includes/update-core.php', true) ) { 257 $wp_filesystem->delete($working_dir, true); 258 return $result; 259 } */ 260 261 require(ABSPATH . 'wp-admin/includes/update-core.php'); 262 263 return update_core($working_dir, $wp_dir); 264 } 265 191 266 ?> -
wp-admin/update.php
44 44 echo '</div>'; 45 45 } 46 46 47 function do_core_upgrade() { 48 global $wp_filesystem; 49 50 $url = wp_nonce_url("update.php?action=upgrade-core", "upgrade-core"); 51 if ( false === ($credentials = request_filesystem_credentials($url)) ) 52 return; 53 54 if ( ! WP_Filesystem($credentials) ) { 55 request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again 56 return; 57 } 58 59 echo '<div class="wrap">'; 60 echo '<h2>' . __('Upgrade WordPress') . '</h2>'; 61 if ( $wp_filesystem->errors->get_error_code() ) { 62 foreach ( $wp_filesystem->errors->get_error_messages() as $message ) 63 show_message($message); 64 echo '</div>'; 65 return; 66 } 67 68 $result = wp_update_core('show_message'); 69 70 if ( is_wp_error($result) ) { 71 show_message($result); 72 if ('up_to_date' != $result->get_error_code() ) 73 show_message( __('Installation Failed') ); 74 } else { 75 show_message( __('WordPress upgraded successfully') ); 76 } 77 echo '</div>'; 78 } 79 47 80 if ( isset($_GET['action']) ) { 48 81 $plugin = isset($_GET['plugin']) ? trim($_GET['plugin']) : ''; 49 82 … … 84 117 include(WP_PLUGIN_DIR . '/' . $plugin); 85 118 } 86 119 echo "</body></html>"; 120 } elseif ( 'upgrade-core' == $_GET['action'] ) { 121 //check_admin_referer('upgrade-core'); 122 $title = __('Upgrade WordPress'); 123 $parent_file = 'index.php'; 124 require_once('admin-header.php'); 125 do_core_upgrade(); 126 include('admin-footer.php'); 87 127 } 88 128 } 89 129
