<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[50785] trunk/src/wp-admin/includes/update-core.php: Coding Standards: Use strict comparison in `wp-admin/includes/update-core.php`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/50785">50785</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/50785","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2021-04-23 14:49:51 +0000 (Fri, 23 Apr 2021)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Coding Standards: Use strict comparison in `wp-admin/includes/update-core.php`.
Includes minor code layout fixes for better readability.
See <a href="https://core.trac.wordpress.org/ticket/52627">#52627</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesupdatecorephp">trunk/src/wp-admin/includes/update-core.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesupdatecorephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/update-core.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/update-core.php 2021-04-22 22:56:40 UTC (rev 50784)
+++ trunk/src/wp-admin/includes/update-core.php 2021-04-23 14:49:51 UTC (rev 50785)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -924,14 +924,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Sanity check the unzipped distribution.
</span><span class="cx" style="display: block; padding: 0 10px"> $distro = '';
</span><span class="cx" style="display: block; padding: 0 10px"> $roots = array( '/wordpress/', '/wordpress-mu/' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $roots as $root ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $wp_filesystem->exists( $from . $root . 'readme.html' ) && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $wp_filesystem->exists( $from . $root . 'readme.html' )
+ && $wp_filesystem->exists( $from . $root . 'wp-includes/version.php' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $distro = $root;
</span><span class="cx" style="display: block; padding: 0 10px"> break;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $distro ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->delete( $from, true );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'insane_distro', __( 'The update could not be unpacked' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -942,9 +947,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * BC Note: $wp_filesystem->wp_content_dir() returned unslashed pre-2.8.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $versions_file = trailingslashit( $wp_filesystem->wp_content_dir() ) . 'upgrade/version-current.php';
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $versions_file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->delete( $from, true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ return new WP_Error(
+ 'copy_failed_for_version_file',
+ __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ),
+ 'wp-includes/version.php'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->chmod( $versions_file, FS_CHMOD_FILE );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -965,6 +976,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
</span><span class="cx" style="display: block; padding: 0 10px"> $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
</span><span class="cx" style="display: block; padding: 0 10px"> $php_compat = version_compare( $php_version, $required_php_version, '>=' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $mysql_compat = true;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1057,23 +1069,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2.
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_array( $checksums ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $checksums as $file => $checksum ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'wp-content' === substr( $file, 0, 10 ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( ABSPATH . $file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( $working_dir_local . $file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( '.' === dirname( $file )
+ && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( md5_file( ABSPATH . $file ) === $checksum ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $skip[] = $file;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1086,11 +1106,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // If we're using the direct method, we can predict write failures that are due to permissions.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $check_is_writable && 'direct' === $wp_filesystem->method ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $files_writable = array_filter( $check_is_writable, array( $wp_filesystem, 'is_writable' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $files_writable !== $check_is_writable ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $files_not_writable = array_diff_key( $check_is_writable, $files_writable );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $files_not_writable as $relative_file_not_writable => $file_not_writable ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // If the writable check failed, chmod file to 0644 and try again, same as copy_dir().
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->chmod( $file_not_writable, FS_CHMOD_FILE );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $wp_filesystem->is_writable( $file_not_writable ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $files_not_writable[ $relative_file_not_writable ] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1100,7 +1123,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $error_data = version_compare( $old_wp_version, '3.7-beta2', '>' ) ? array_keys( $files_not_writable ) : '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $files_not_writable ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return new WP_Error( 'files_not_writable', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), implode( ', ', $error_data ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return new WP_Error(
+ 'files_not_writable',
+ __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ),
+ implode( ', ', $error_data )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1107,6 +1134,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-admin/includes/update-core.php */
</span><span class="cx" style="display: block; padding: 0 10px"> apply_filters( 'update_feedback', __( 'Enabling Maintenance mode…' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Create maintenance file to signal that we are upgrading.
</span><span class="cx" style="display: block; padding: 0 10px"> $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
</span><span class="cx" style="display: block; padding: 0 10px"> $maintenance_file = $to . '.maintenance';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1115,10 +1143,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-admin/includes/update-core.php */
</span><span class="cx" style="display: block; padding: 0 10px"> apply_filters( 'update_feedback', __( 'Copying the required files…' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Copy new versions of WP files into place.
</span><span class="cx" style="display: block; padding: 0 10px"> $result = _copy_dir( $from . $distro, $to, $skip );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $result ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = new WP_Error(
+ $result->get_error_code(),
+ $result->get_error_message(),
+ substr( $result->get_error_data(), strlen( $to ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Since we know the core files have copied over, we can now copy the version file.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1125,8 +1159,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->delete( $from, true );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = new WP_Error( 'copy_failed_for_version_file', __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ), 'wp-includes/version.php' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = new WP_Error(
+ 'copy_failed_for_version_file',
+ __( 'The update cannot be installed because we will be unable to copy some files. This is usually due to inconsistent file permissions.' ),
+ 'wp-includes/version.php'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1141,19 +1180,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Check to make sure everything copied correctly, ignoring the contents of wp-content.
</span><span class="cx" style="display: block; padding: 0 10px"> $skip = array( 'wp-content' );
</span><span class="cx" style="display: block; padding: 0 10px"> $failed = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $checksums ) && is_array( $checksums ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $checksums as $file => $checksum ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'wp-content' === substr( $file, 0, 10 ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! file_exists( $working_dir_local . $file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( '.' === dirname( $file ) && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( '.' === dirname( $file )
+ && in_array( pathinfo( $file, PATHINFO_EXTENSION ), array( 'html', 'txt' ), true )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $skip[] = $file;
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) == $checksum ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ if ( file_exists( ABSPATH . $file ) && md5_file( ABSPATH . $file ) === $checksum ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $skip[] = $file;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $failed[] = $file;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1164,6 +1209,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Some files didn't copy properly.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! empty( $failed ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $total_size = 0;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $failed as $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( file_exists( $working_dir_local . $file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $total_size += filesize( $working_dir_local . $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1173,12 +1219,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // If we don't have enough free space, it isn't worth trying again.
</span><span class="cx" style="display: block; padding: 0 10px"> // Unlikely to be hit due to the check in unzip_file().
</span><span class="cx" style="display: block; padding: 0 10px"> $available_space = @disk_free_space( ABSPATH );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $available_space && $total_size >= $available_space ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = new WP_Error( 'disk_full', __( 'There is not enough free disk space to complete the update.' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = _copy_dir( $from . $distro, $to, $skip );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $result ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = new WP_Error( $result->get_error_code() . '_retry', $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = new WP_Error(
+ $result->get_error_code() . '_retry',
+ $result->get_error_message(),
+ substr( $result->get_error_data(), strlen( $to ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1186,7 +1238,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Custom content directory needs updating now.
</span><span class="cx" style="display: block; padding: 0 10px"> // Copy languages.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( WP_LANG_DIR !== ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $lang_dir = WP_LANG_DIR;
</span><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><span class="cx" style="display: block; padding: 0 10px"> $lang_dir = WP_CONTENT_DIR . '/languages';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1201,10 +1253,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( @is_dir( $lang_dir ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_lang_dir = $wp_filesystem->find_folder( $lang_dir );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $wp_lang_dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = copy_dir( $from . $distro . 'wp-content/languages/', $wp_lang_dir );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $result ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = new WP_Error( $result->get_error_code() . '_languages', $result->get_error_message(), substr( $result->get_error_data(), strlen( $wp_lang_dir ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = new WP_Error(
+ $result->get_error_code() . '_languages',
+ $result->get_error_message(),
+ substr( $result->get_error_data(), strlen( $wp_lang_dir ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1212,12 +1270,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-admin/includes/update-core.php */
</span><span class="cx" style="display: block; padding: 0 10px"> apply_filters( 'update_feedback', __( 'Disabling Maintenance mode…' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Remove maintenance file, we're done with potential site-breaking changes.
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->delete( $maintenance_file );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users, preventing installation of Twenty Twelve.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users,
+ // preventing installation of Twenty Twelve.
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( '3.5' === $old_wp_version ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' ) && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' )
+ && ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->delete( $wp_filesystem->wp_themes_dir() . 'twentytwelve/' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1228,7 +1290,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * future versions of WordPress whilst avoiding the re-install upon upgrade issue.
</span><span class="cx" style="display: block; padding: 0 10px"> * $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! is_wp_error( $result ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_wp_error( $result )
+ && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // If a $development_build or if $introduced version is greater than what the site was previously running.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1271,7 +1335,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $result = new WP_Error;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result->add( $_result->get_error_code() . "_$type", $_result->get_error_message(), substr( $_result->get_error_data(), strlen( $dest ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ $result->add(
+ $_result->get_error_code() . "_$type",
+ $_result->get_error_message(),
+ substr( $_result->get_error_data(), strlen( $dest ) )
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1281,6 +1350,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Handle $result error from the above blocks.
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->delete( $from, true );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return $result;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1287,6 +1357,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Remove old files.
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $_old_files as $old_file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $old_file = $to . $old_file;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_filesystem->exists( $old_file ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1306,6 +1377,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> // Upgrade DB with separate request.
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-admin/includes/update-core.php */
</span><span class="cx" style="display: block; padding: 0 10px"> apply_filters( 'update_feedback', __( 'Upgrading database…' ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> $db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
</span><span class="cx" style="display: block; padding: 0 10px"> wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1387,6 +1459,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // If copy failed, chmod file to 0644 and try again.
</span><span class="cx" style="display: block; padding: 0 10px"> $wp_filesystem->chmod( $to . $filename, FS_CHMOD_FILE );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1411,6 +1484,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * of the existing $skip_list.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $sub_skip_list = array();
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> foreach ( $skip_list as $skip_item ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1418,11 +1492,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $result = _copy_dir( $from . $filename, $to . $filename, $sub_skip_list );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( is_wp_error( $result ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $result;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1516,6 +1592,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $affected_files as $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $gen_dir = $wp_filesystem->find_folder( trailingslashit( dirname( $file ) ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $gen_dir ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> continue;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1546,11 +1623,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $directory = trailingslashit( $directory );
</span><span class="cx" style="display: block; padding: 0 10px"> $files = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( file_exists( "{$directory}example.html" ) && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' ) ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( file_exists( "{$directory}example.html" )
+ && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' )
+ ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $files[] = "{$directory}example.html";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $dirs = glob( $directory . '*', GLOB_ONLYDIR );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $dirs ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $dirs as $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $files = array_merge( $files, _upgrade_422_find_genericons_files_in_folder( $dir ) );
</span></span></pre>
</div>
</div>
</body>
</html>