Make WordPress Core

Ticket #48074: 48074-src-Remove-work-arounds-for-PHP-5.6.patch

File 48074-src-Remove-work-arounds-for-PHP-5.6.patch, 4.4 KB (added by jrf, 5 years ago)

This patch removes all code using a version_compare() with a PHP version older than PHP 5.6.

  • src/wp-includes/class-wp-customize-manager.php

    From 08821279dd493b64ffc78085cd724094a1cd3baa Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Sat, 27 Jul 2019 01:32:32 +0200
    Subject: [PATCH] [src] Remove work-arounds for PHP < 5.6
    
    ---
     src/wp-includes/class-wp-customize-manager.php |  7 -------
     src/wp-includes/class-wp-locale.php            |  9 ++-------
     src/wp-includes/formatting.php                 | 16 +++-------------
     src/wp-includes/functions.php                  |  7 +------
     4 files changed, 6 insertions(+), 33 deletions(-)
    
    diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php
    index 1948e7a794..b7cdf27400 100644
    a b final class WP_Customize_Manager { 
    13751375                                                )
    13761376                                        );
    13771377
    1378                                         // In PHP < 5.6 filesize() returns 0 for the temp files unless we clear the file status cache.
    1379                                         // Technically, PHP < 5.6.0 || < 5.5.13 || < 5.4.29 but no need to be so targeted.
    1380                                         // See https://bugs.php.net/bug.php?id=65701
    1381                                         if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
    1382                                                 clearstatcache();
    1383                                         }
    1384 
    13851378                                        $attachment_id = media_handle_sideload( $file_array, 0, null, $attachment_post_data );
    13861379                                        if ( is_wp_error( $attachment_id ) ) {
    13871380                                                continue;
  • src/wp-includes/class-wp-locale.php

    diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-wp-locale.php
    index 8582964a07..875a061568 100644
    a b class WP_Locale { 
    199199                /* translators: $thousands_sep argument for https://secure.php.net/number_format, default is ',' */
    200200                $thousands_sep = __( 'number_format_thousands_sep' );
    201201
    202                 if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
    203                         // Replace space with a non-breaking space to avoid wrapping.
    204                         $thousands_sep = str_replace( ' ', '&nbsp;', $thousands_sep );
    205                 } else {
    206                         // PHP < 5.4.0 does not support multiple bytes in thousands separator.
    207                         $thousands_sep = str_replace( array( '&nbsp;', '&#160;' ), ' ', $thousands_sep );
    208                 }
     202                // Replace space with a non-breaking space to avoid wrapping.
     203                $thousands_sep = str_replace( ' ', '&nbsp;', $thousands_sep );
    209204
    210205                $this->number_format['thousands_sep'] = ( 'number_format_thousands_sep' === $thousands_sep ) ? ',' : $thousands_sep;
    211206
  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index feed291794..63397aea5d 100644
    a b function _print_emoji_detection_script() { 
    55725572 * @return string The encoded content.
    55735573 */
    55745574function wp_encode_emoji( $content ) {
    5575         $emoji  = _wp_emoji_list( 'partials' );
    5576         $compat = version_compare( phpversion(), '5.4', '<' );
     5575        $emoji = _wp_emoji_list( 'partials' );
    55775576
    55785577        foreach ( $emoji as $emojum ) {
    5579                 if ( $compat ) {
    5580                         $emoji_char = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
    5581                 } else {
    5582                         $emoji_char = html_entity_decode( $emojum );
    5583                 }
     5578                $emoji_char = html_entity_decode( $emojum );
    55845579                if ( false !== strpos( $content, $emoji_char ) ) {
    55855580                        $content = preg_replace( "/$emoji_char/", $emojum, $content );
    55865581                }
    function wp_staticize_emoji( $text ) { 
    56165611
    56175612        // Quickly narrow down the list of emoji that might be in the text and need replacing.
    56185613        $possible_emoji = array();
    5619         $compat         = version_compare( phpversion(), '5.4', '<' );
    56205614        foreach ( $emoji as $emojum ) {
    56215615                if ( false !== strpos( $text, $emojum ) ) {
    5622                         if ( $compat ) {
    5623                                 $possible_emoji[ $emojum ] = html_entity_decode( $emojum, ENT_COMPAT, 'UTF-8' );
    5624                         } else {
    5625                                 $possible_emoji[ $emojum ] = html_entity_decode( $emojum );
    5626                         }
     5616                        $possible_emoji[ $emojum ] = html_entity_decode( $emojum );
    56275617                }
    56285618        }
    56295619
  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index d6230bd478..ff8ba87686 100644
    a b function wp_allowed_protocols() { 
    60536053function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
    60546054        static $truncate_paths;
    60556055
    6056         if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) {
    6057                 $trace = debug_backtrace( false );
    6058         } else {
    6059                 $trace = debug_backtrace();
    6060         }
    6061 
     6056        $trace       = debug_backtrace( false );
    60626057        $caller      = array();
    60636058        $check_class = ! is_null( $ignore_class );
    60646059        $skip_frames++; // skip this function