Make WordPress Core

Changeset 56088


Ignore:
Timestamp:
06/28/2023 10:07:49 AM (10 months ago)
Author:
azaozz
Message:

Revert use of str_starts_with() and str_contains() in update-core.php.

Fixes updating WordPress from 5.7 and earlier versions. When updating this file runs first in the old version where the polifills may not be available.

Props: ironprogrammer, SergeyBiryukov, dd32, azaozz.
See: #58206.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/update-core.php

    r55990 r56088  
    11381138    $wp_filesystem->delete( $versions_file );
    11391139
    1140     $php_version       = PHP_VERSION;
    1141     $mysql_version     = $wpdb->db_version();
    1142     $old_wp_version    = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
    1143     $development_build = ( str_contains( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
     1140    $php_version    = PHP_VERSION;
     1141    $mysql_version  = $wpdb->db_version();
     1142    $old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
     1143    /*
     1144     * Note: str_contains() is not used here, as this file is included
     1145     * when updating from older WordPress versions, in which case
     1146     * the polyfills from wp-includes/compat.php may not be available.
     1147     */
     1148    $development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
    11441149    $php_compat        = version_compare( $php_version, $required_php_version, '>=' );
    11451150
     
    12431248        if ( is_array( $checksums ) ) {
    12441249            foreach ( $checksums as $file => $checksum ) {
    1245                 if ( str_starts_with( $file, 'wp-content' ) ) {
     1250                /*
     1251                 * Note: str_starts_with() is not used here, as this file is included
     1252                 * when updating from older WordPress versions, in which case
     1253                 * the polyfills from wp-includes/compat.php may not be available.
     1254                 */
     1255                if ( 'wp-content' === substr( $file, 0, 10 ) ) {
    12461256                    continue;
    12471257                }
     
    13501360    if ( isset( $checksums ) && is_array( $checksums ) ) {
    13511361        foreach ( $checksums as $file => $checksum ) {
    1352             if ( str_starts_with( $file, 'wp-content' ) ) {
     1362            /*
     1363             * Note: str_starts_with() is not used here, as this file is included
     1364             * when updating from older WordPress versions, in which case
     1365             * the polyfills from wp-includes/compat.php may not be available.
     1366             */
     1367            if ( 'wp-content' === substr( $file, 0, 10 ) ) {
    13531368                continue;
    13541369            }
     
    17651780
    17661781    if ( file_exists( "{$directory}example.html" )
    1767         && str_contains( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' )
     1782        /*
     1783         * Note: str_contains() is not used here, as this file is included
     1784         * when updating from older WordPress versions, in which case
     1785         * the polyfills from wp-includes/compat.php may not be available.
     1786         */
     1787        && false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' )
    17681788    ) {
    17691789        $files[] = "{$directory}example.html";
     
    17741794        $dirs,
    17751795        static function( $dir ) {
    1776             // Skip any node_modules directories.
    1777             return ! str_contains( $dir, 'node_modules' );
     1796            /*
     1797             * Skip any node_modules directories.
     1798             *
     1799             * Note: str_contains() is not used here, as this file is included
     1800             * when updating from older WordPress versions, in which case
     1801             * the polyfills from wp-includes/compat.php may not be available.
     1802             */
     1803            return false === strpos( $dir, 'node_modules' );
    17781804        }
    17791805    );
Note: See TracChangeset for help on using the changeset viewer.