raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * WordPress core upgrade functionality.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 * @since 2.7.0
mp-wp_genesis 8 */
mp-wp_genesis 9
mp-wp_genesis 10 /**
mp-wp_genesis 11 * Stores files to be deleted.
mp-wp_genesis 12 *
mp-wp_genesis 13 * @since 2.7.0
mp-wp_genesis 14 * @global array $_old_files
mp-wp_genesis 15 * @var array
mp-wp_genesis 16 * @name $_old_files
mp-wp_genesis 17 */
mp-wp_genesis 18 global $_old_files;
mp-wp_genesis 19
mp-wp_genesis 20 $_old_files = array(
mp-wp_genesis 21 'wp-admin/bookmarklet.php',
mp-wp_genesis 22 'wp-admin/css/upload.css',
mp-wp_genesis 23 'wp-admin/css/upload-rtl.css',
mp-wp_genesis 24 'wp-admin/css/press-this-ie.css',
mp-wp_genesis 25 'wp-admin/css/press-this-ie-rtl.css',
mp-wp_genesis 26 'wp-admin/edit-form.php',
mp-wp_genesis 27 'wp-admin/link-import.php',
mp-wp_update-imag... 28 'wp-admin/images/box-bg-left.svg',
mp-wp_update-imag... 29 'wp-admin/images/box-bg-right.svg',
mp-wp_update-imag... 30 'wp-admin/images/box-bg.svg',
mp-wp_update-imag... 31 'wp-admin/images/box-butt-left.svg',
mp-wp_update-imag... 32 'wp-admin/images/box-butt-right.svg',
mp-wp_update-imag... 33 'wp-admin/images/box-butt.svg',
mp-wp_update-imag... 34 'wp-admin/images/box-head-left.svg',
mp-wp_update-imag... 35 'wp-admin/images/box-head-right.svg',
mp-wp_update-imag... 36 'wp-admin/images/box-head.svg',
mp-wp_update-imag... 37 'wp-admin/images/heading-bg.svg',
mp-wp_update-imag... 38 'wp-admin/images/login-bkg-bottom.svg',
mp-wp_update-imag... 39 'wp-admin/images/login-bkg-tile.svg',
mp-wp_update-imag... 40 'wp-admin/images/notice.svg',
mp-wp_update-imag... 41 'wp-admin/images/toggle.svg',
mp-wp_update-imag... 42 'wp-admin/images/comment-stalk-classic.svg',
mp-wp_update-imag... 43 'wp-admin/images/comment-stalk-fresh.svg',
mp-wp_update-imag... 44 'wp-admin/images/comment-stalk-rtl.svg',
mp-wp_update-imag... 45 'wp-admin/images/comment-pill.svg',
mp-wp_update-imag... 46 'wp-admin/images/del.svg',
mp-wp_update-imag... 47 'wp-admin/images/media-button-gallery.svg',
mp-wp_update-imag... 48 'wp-admin/images/media-buttons.svg',
mp-wp_update-imag... 49 'wp-admin/images/tail.svg',
mp-wp_update-imag... 50 'wp-admin/images/gear.svg',
mp-wp_update-imag... 51 'wp-admin/images/tab.svg',
mp-wp_update-imag... 52 'wp-admin/images/postbox-bg.svg',
mp-wp_genesis 53 'wp-admin/includes/upload.php',
mp-wp_genesis 54 'wp-admin/js/dbx-admin-key.js',
mp-wp_genesis 55 'wp-admin/js/link-cat.js',
mp-wp_genesis 56 'wp-admin/js/forms.js',
mp-wp_genesis 57 'wp-admin/js/upload.js',
mp-wp_genesis 58 'wp-admin/profile-update.php',
mp-wp_genesis 59 'wp-admin/templates.php',
mp-wp_update-imag... 60 'wp-includes/images/audio.svg',
mp-wp_update-imag... 61 'wp-includes/images/css.svg',
mp-wp_update-imag... 62 'wp-includes/images/default.svg',
mp-wp_update-imag... 63 'wp-includes/images/doc.svg',
mp-wp_update-imag... 64 'wp-includes/images/exe.svg',
mp-wp_update-imag... 65 'wp-includes/images/html.svg',
mp-wp_update-imag... 66 'wp-includes/images/js.svg',
mp-wp_update-imag... 67 'wp-includes/images/pdf.svg',
mp-wp_update-imag... 68 'wp-includes/images/swf.svg',
mp-wp_update-imag... 69 'wp-includes/images/tar.svg',
mp-wp_update-imag... 70 'wp-includes/images/text.svg',
mp-wp_update-imag... 71 'wp-includes/images/video.svg',
mp-wp_update-imag... 72 'wp-includes/images/zip.svg',
mp-wp_genesis 73 'wp-includes/js/dbx.js',
mp-wp_genesis 74 'wp-includes/js/fat.js',
mp-wp_genesis 75 'wp-includes/js/list-manipulation.js',
mp-wp_genesis 76 'wp-includes/js/jquery/jquery.dimensions.min.js',
mp-wp_genesis 77 'wp-includes/js/tinymce/langs/en.js',
mp-wp_genesis 78 'wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js',
mp-wp_genesis 79 'wp-includes/js/tinymce/plugins/autosave/langs',
mp-wp_genesis 80 'wp-includes/js/tinymce/plugins/directionality/images',
mp-wp_genesis 81 'wp-includes/js/tinymce/plugins/directionality/langs',
mp-wp_genesis 82 'wp-includes/js/tinymce/plugins/inlinepopups/css',
mp-wp_genesis 83 'wp-includes/js/tinymce/plugins/inlinepopups/images',
mp-wp_genesis 84 'wp-includes/js/tinymce/plugins/inlinepopups/jscripts',
mp-wp_genesis 85 'wp-includes/js/tinymce/plugins/paste/images',
mp-wp_genesis 86 'wp-includes/js/tinymce/plugins/paste/jscripts',
mp-wp_genesis 87 'wp-includes/js/tinymce/plugins/paste/langs',
mp-wp_genesis 88 'wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php',
mp-wp_genesis 89 'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php',
mp-wp_genesis 90 'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php',
mp-wp_genesis 91 'wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php',
mp-wp_genesis 92 'wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css',
mp-wp_genesis 93 'wp-includes/js/tinymce/plugins/spellchecker/images',
mp-wp_genesis 94 'wp-includes/js/tinymce/plugins/spellchecker/langs',
mp-wp_genesis 95 'wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php',
mp-wp_genesis 96 'wp-includes/js/tinymce/plugins/wordpress/images',
mp-wp_genesis 97 'wp-includes/js/tinymce/plugins/wordpress/langs',
mp-wp_genesis 98 'wp-includes/js/tinymce/plugins/wordpress/popups.css',
mp-wp_genesis 99 'wp-includes/js/tinymce/plugins/wordpress/wordpress.css',
mp-wp_genesis 100 'wp-includes/js/tinymce/plugins/wphelp',
mp-wp_genesis 101 'wp-includes/js/tinymce/themes/advanced/css',
mp-wp_genesis 102 'wp-includes/js/tinymce/themes/advanced/images',
mp-wp_genesis 103 'wp-includes/js/tinymce/themes/advanced/jscripts',
mp-wp_genesis 104 'wp-includes/js/tinymce/themes/advanced/langs',
mp-wp_genesis 105 'wp-includes/js/tinymce/tiny_mce_gzip.php',
mp-wp_genesis 106 'wp-includes/js/wp-ajax.js',
mp-wp_genesis 107 'wp-admin/admin-db.php',
mp-wp_genesis 108 'wp-admin/cat.js',
mp-wp_genesis 109 'wp-admin/categories.js',
mp-wp_genesis 110 'wp-admin/custom-fields.js',
mp-wp_genesis 111 'wp-admin/dbx-admin-key.js',
mp-wp_genesis 112 'wp-admin/edit-comments.js',
mp-wp_genesis 113 'wp-admin/install-rtl.css',
mp-wp_genesis 114 'wp-admin/install.css',
mp-wp_genesis 115 'wp-admin/upgrade-schema.php',
mp-wp_genesis 116 'wp-admin/upload-functions.php',
mp-wp_genesis 117 'wp-admin/upload-rtl.css',
mp-wp_genesis 118 'wp-admin/upload.css',
mp-wp_genesis 119 'wp-admin/upload.js',
mp-wp_genesis 120 'wp-admin/users.js',
mp-wp_genesis 121 'wp-admin/widgets-rtl.css',
mp-wp_genesis 122 'wp-admin/widgets.css',
mp-wp_genesis 123 'wp-admin/xfn.js',
mp-wp_genesis 124 'wp-includes/js/tinymce/license.html',
mp-wp_genesis 125 'wp-admin/cat-js.php',
mp-wp_genesis 126 'wp-admin/edit-form-ajax-cat.php',
mp-wp_genesis 127 'wp-admin/execute-pings.php',
mp-wp_genesis 128 'wp-admin/import/b2.php',
mp-wp_genesis 129 'wp-admin/inline-uploading.php',
mp-wp_genesis 130 'wp-admin/link-categories.php',
mp-wp_genesis 131 'wp-admin/list-manipulation.js',
mp-wp_genesis 132 'wp-admin/list-manipulation.php',
mp-wp_genesis 133 'wp-includes/comment-functions.php',
mp-wp_genesis 134 'wp-includes/feed-functions.php',
mp-wp_genesis 135 'wp-includes/functions-compat.php',
mp-wp_genesis 136 'wp-includes/functions-formatting.php',
mp-wp_genesis 137 'wp-includes/functions-post.php',
mp-wp_genesis 138 'wp-includes/js/dbx-key.js',
mp-wp_genesis 139 'wp-includes/js/tinymce/plugins/autosave/langs/cs.js',
mp-wp_genesis 140 'wp-includes/js/tinymce/plugins/autosave/langs/sv.js',
mp-wp_genesis 141 'wp-includes/js/tinymce/themes/advanced/editor_template_src.js',
mp-wp_genesis 142 'wp-includes/links.php',
mp-wp_genesis 143 'wp-includes/pluggable-functions.php',
mp-wp_genesis 144 'wp-includes/template-functions-author.php',
mp-wp_genesis 145 'wp-includes/template-functions-category.php',
mp-wp_genesis 146 'wp-includes/template-functions-general.php',
mp-wp_genesis 147 'wp-includes/template-functions-links.php',
mp-wp_genesis 148 'wp-includes/template-functions-post.php',
mp-wp_genesis 149 'wp-includes/wp-l10n.php',
mp-wp_genesis 150 'wp-admin/import-b2.php',
mp-wp_genesis 151 'wp-admin/import-blogger.php',
mp-wp_genesis 152 'wp-admin/import-greymatter.php',
mp-wp_genesis 153 'wp-admin/import-livejournal.php',
mp-wp_genesis 154 'wp-admin/import-mt.php',
mp-wp_genesis 155 'wp-admin/import-rss.php',
mp-wp_genesis 156 'wp-admin/import-textpattern.php',
mp-wp_genesis 157 'wp-admin/quicktags.js',
mp-wp_update-imag... 158 'wp-images/fade-butt.svg',
mp-wp_update-imag... 159 'wp-images/get-firefox.svg',
mp-wp_update-imag... 160 'wp-images/header-shadow.svg',
mp-wp_genesis 161 'wp-images/smilies',
mp-wp_update-imag... 162 'wp-images/wp-small.svg',
mp-wp_update-imag... 163 'wp-images/wpminilogo.svg',
mp-wp_genesis 164 'wp.php',
mp-wp_genesis 165 'wp-content/themes/default/attachment.php',
mp-wp_genesis 166 'wp-content/themes/default/images/kubrickbg.jpg',
mp-wp_genesis 167 'wp-content/plugins/markdown.php',
mp-wp_genesis 168 'wp-content/plugins/textile1.php',
mp-wp_genesis 169 );
mp-wp_genesis 170
mp-wp_genesis 171 /**
mp-wp_genesis 172 * Upgrade the core of WordPress.
mp-wp_genesis 173 *
mp-wp_genesis 174 * This will create a .maintenance file at the base of the WordPress directory
mp-wp_genesis 175 * to ensure that people can not access the web site, when the files are being
mp-wp_genesis 176 * copied to their locations.
mp-wp_genesis 177 *
mp-wp_genesis 178 * The files in the {@link $_old_files} list will be removed and the new files
mp-wp_genesis 179 * copied from the zip file after the database is upgraded.
mp-wp_genesis 180 *
mp-wp_genesis 181 * The steps for the upgrader for after the new release is downloaded and
mp-wp_genesis 182 * unzipped is:
mp-wp_genesis 183 * 1. Test unzipped location for select files to ensure that unzipped worked.
mp-wp_genesis 184 * 2. Create the .maintenance file in current WordPress base.
mp-wp_genesis 185 * 3. Copy new WordPress directory over old WordPress files.
mp-wp_genesis 186 * 4. Upgrade WordPress to new version.
mp-wp_genesis 187 * 5. Delete new WordPress directory path.
mp-wp_genesis 188 * 6. Delete .maintenance file.
mp-wp_genesis 189 * 7. Remove old files.
mp-wp_genesis 190 * 8. Delete 'update_core' option.
mp-wp_genesis 191 *
mp-wp_genesis 192 * There are several areas of failure. For instance if PHP times out before step
mp-wp_genesis 193 * 6, then you will not be able to access any portion of your site. Also, since
mp-wp_genesis 194 * the upgrade will not continue where it left off, you will not be able to
mp-wp_genesis 195 * automatically remove old files and remove the 'update_core' option. This
mp-wp_genesis 196 * isn't that bad.
mp-wp_genesis 197 *
mp-wp_genesis 198 * If the copy of the new WordPress over the old fails, then the worse is that
mp-wp_genesis 199 * the new WordPress directory will remain.
mp-wp_genesis 200 *
mp-wp_genesis 201 * If it is assumed that every file will be copied over, including plugins and
mp-wp_genesis 202 * themes, then if you edit the default theme, you should rename it, so that
mp-wp_genesis 203 * your changes remain.
mp-wp_genesis 204 *
mp-wp_genesis 205 * @since 2.7.0
mp-wp_genesis 206 *
mp-wp_genesis 207 * @param string $from New release unzipped path.
mp-wp_genesis 208 * @param string $to Path to old WordPress installation.
mp-wp_genesis 209 * @return WP_Error|null WP_Error on failure, null on success.
mp-wp_genesis 210 */
mp-wp_genesis 211 function update_core($from, $to) {
mp-wp_genesis 212 global $wp_filesystem, $_old_files;
mp-wp_genesis 213
mp-wp_genesis 214 @set_time_limit( 300 );
mp-wp_genesis 215
mp-wp_genesis 216 // Sanity check the unzipped distribution
mp-wp_genesis 217 apply_filters('update_feedback', __('Verifying the unpacked files'));
mp-wp_genesis 218 if ( !$wp_filesystem->exists($from . '/wordpress/wp-settings.php') || !$wp_filesystem->exists($from . '/wordpress/wp-admin/admin.php') ||
mp-wp_genesis 219 !$wp_filesystem->exists($from . '/wordpress/wp-includes/functions.php') ) {
mp-wp_genesis 220 $wp_filesystem->delete($from, true);
mp-wp_genesis 221 return new WP_Error('insane_distro', __('The update could not be unpacked') );
mp-wp_genesis 222 }
mp-wp_genesis 223
mp-wp_genesis 224 apply_filters('update_feedback', __('Installing the latest version'));
mp-wp_genesis 225
mp-wp_genesis 226 // Create maintenance file to signal that we are upgrading
mp-wp_genesis 227 $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
mp-wp_genesis 228 $maintenance_file = $to . '.maintenance';
mp-wp_genesis 229 $wp_filesystem->delete($maintenance_file);
mp-wp_genesis 230 $wp_filesystem->put_contents($maintenance_file, $maintenance_string, FS_CHMOD_FILE);
mp-wp_genesis 231
mp-wp_genesis 232 // Copy new versions of WP files into place.
mp-wp_genesis 233 $result = copy_dir($from . '/wordpress', $to);
mp-wp_genesis 234 if ( is_wp_error($result) ) {
mp-wp_genesis 235 $wp_filesystem->delete($maintenance_file);
mp-wp_genesis 236 //$wp_filesystem->delete($working_dir, true); //TODO: Uncomment? This DOES mean that the new files are available in the upgrade folder if it fails.
mp-wp_genesis 237 return $result;
mp-wp_genesis 238 }
mp-wp_genesis 239
mp-wp_genesis 240 // Remove old files
mp-wp_genesis 241 foreach ( $_old_files as $old_file ) {
mp-wp_genesis 242 $old_file = $to . $old_file;
mp-wp_genesis 243 if ( !$wp_filesystem->exists($old_file) )
mp-wp_genesis 244 continue;
mp-wp_genesis 245 $wp_filesystem->delete($old_file, true);
mp-wp_genesis 246 }
mp-wp_genesis 247
mp-wp_genesis 248 // Upgrade DB with separate request
mp-wp_genesis 249 apply_filters('update_feedback', __('Upgrading database'));
mp-wp_genesis 250 $db_upgrade_url = admin_url('upgrade.php?step=upgrade_db');
mp-wp_genesis 251 wp_remote_post($db_upgrade_url, array('timeout' => 60));
mp-wp_genesis 252
mp-wp_genesis 253 // Remove working directory
mp-wp_genesis 254 $wp_filesystem->delete($from, true);
mp-wp_genesis 255
mp-wp_genesis 256 // Force refresh of update information
mp-wp_genesis 257 delete_option('update_core');
mp-wp_genesis 258
mp-wp_genesis 259 // Remove maintenance file, we're done.
mp-wp_genesis 260 $wp_filesystem->delete($maintenance_file);
mp-wp_genesis 261 }
mp-wp_genesis 262
mp-wp_genesis 263 ?>