WordPress.org

Make WordPress Core

Changeset 46214


Ignore:
Timestamp:
09/20/2019 10:01:36 PM (2 months ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Remove all code using a version_compare() with a PHP version older than PHP 5.6.

Props jrf.
Fixes #48074.

Location:
trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpunit.xml.dist

    r45607 r46214  
    99        <testsuite name="default">
    1010            <directory suffix=".php">tests/phpunit/tests</directory>
    11             <file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file>
    12             <file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file>
    13             <file phpVersion="5.3.0">tests/phpunit/tests/image/editorGd.php</file>
    14             <file phpVersion="5.3.0">tests/phpunit/tests/image/editorImagick.php</file>
    15             <file phpVersion="5.3.0">tests/phpunit/tests/oembed/headers.php</file>
    16             <exclude>tests/phpunit/tests/actions/closures.php</exclude>
    17             <exclude>tests/phpunit/tests/image/editor.php</exclude>
    18             <exclude>tests/phpunit/tests/image/editorGd.php</exclude>
    19             <exclude>tests/phpunit/tests/image/editorImagick.php</exclude>
    20             <exclude>tests/phpunit/tests/oembed/headers.php</exclude>
    2111            <exclude>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</exclude>
    2212        </testsuite>
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r46206 r46214  
    13761376                        )
    13771377                    );
    1378 
    1379                     // In PHP < 5.6 filesize() returns 0 for the temp files unless we clear the file status cache.
    1380                     // Technically, PHP < 5.6.0 || < 5.5.13 || < 5.4.29 but no need to be so targeted.
    1381                     // See https://bugs.php.net/bug.php?id=65701
    1382                     if ( version_compare( PHP_VERSION, '5.6', '<' ) ) {
    1383                         clearstatcache();
    1384                     }
    13851378
    13861379                    $attachment_id = media_handle_sideload( $file_array, 0, null, $attachment_post_data );
  • trunk/src/wp-includes/class-wp-locale.php

    r45932 r46214  
    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;
  • trunk/src/wp-includes/formatting.php

    r46164 r46214  
    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 );
     
    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    }
  • trunk/src/wp-includes/functions.php

    r46206 r46214  
    60056005    static $truncate_paths;
    60066006
    6007     if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) {
    6008         $trace = debug_backtrace( false );
    6009     } else {
    6010         $trace = debug_backtrace();
    6011     }
    6012 
     6007    $trace       = debug_backtrace( false );
    60136008    $caller      = array();
    60146009    $check_class = ! is_null( $ignore_class );
  • trunk/tests/phpunit/includes/utils.php

    r46127 r46214  
    466466    $saved_config = ini_get( 'pcre.backtrack_limit' );
    467467
    468     // Attempt to prevent PHP crashes.  Adjust these lower when needed.
    469     if ( version_compare( phpversion(), '5.4.8', '>' ) ) {
    470         $limit = 1000000;
    471     } else {
    472         $limit = 20000;  // 20,000 is a reasonable upper limit, but see also https://core.trac.wordpress.org/ticket/29557#comment:10
    473     }
     468    // Attempt to prevent PHP crashes. Adjust these lower when needed.
     469    $limit = 1000000;
    474470
    475471    // Start with small numbers, so if a crash is encountered at higher numbers we can still debug the problem.
  • trunk/tests/phpunit/multisite.xml

    r44790 r46214  
    1313        <testsuite name="default">
    1414            <directory suffix=".php">tests</directory>
    15             <file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file>
    16             <file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file>
    17             <file phpVersion="5.3.0">tests/phpunit/tests/image/editorGd.php</file>
    18             <file phpVersion="5.3.0">tests/phpunit/tests/image/editorImagick.php</file>
    19             <exclude>tests/phpunit/tests/actions/closures.php</exclude>
    20             <exclude>tests/phpunit/tests/image/editor.php</exclude>
    21             <exclude>tests/phpunit/tests/image/editorGd.php</exclude>
    22             <exclude>tests/phpunit/tests/image/editorImagick.php</exclude>
    2315            <!-- Path relative to the checkout root, for PHPUnit 3.6.x -->
    2416            <exclude>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</exclude>
  • trunk/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php

    r44628 r46214  
    2525     */
    2626    public function get_mocked_class_instance() {
    27         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    28             $this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' );
    29         }
    30 
    3127        $args = array(
    3228            'plural'   => 'privacy_requests',
  • trunk/tests/phpunit/tests/compat.php

    r46205 r46214  
    250250        }
    251251
    252         if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
    253             $this->markTestSkipped( 'ResourceBundle is only countable in PHP 5.4+' );
    254             return;
    255         }
    256 
    257252        $this->assertTrue( is_countable( new ResourceBundle( 'en', null ) ) );
    258253    }
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r43571 r46214  
    10841084
    10851085        // Add global namespace prefix to check #41488.
    1086         if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) {
    1087             $original_args['fallback_cb'] = '\\' . $original_args['fallback_cb'];
    1088         }
     1086        $original_args['fallback_cb'] = '\\' . $original_args['fallback_cb'];
    10891087
    10901088        $args = $menus->filter_wp_nav_menu_args( $original_args );
  • trunk/tests/phpunit/tests/db/charset.php

    r45607 r46214  
    483483     */
    484484    function test_strip_invalid_text( $data, $expected, $message ) {
    485         if ( version_compare( PHP_VERSION, '5.3', '<' ) && stristr( php_uname( 's' ), 'win' ) ) {
    486             $this->markTestSkipped( 'This test fails in PHP 5.2 on Windows. See https://core.trac.wordpress.org/ticket/31262' );
    487         }
    488 
    489485        $charset = self::$_wpdb->charset;
    490486        if ( isset( $data[0]['connection_charset'] ) ) {
  • trunk/tests/phpunit/tests/functions.php

    r45755 r46214  
    919919     */
    920920    function test_wp_json_encode_depth() {
    921         if ( version_compare( PHP_VERSION, '5.5', '<' ) ) {
    922             $this->markTestSkipped( 'json_encode() supports the $depth parameter in PHP 5.5+' );
    923         };
    924 
    925921        $data = array( array( array( 1, 2, 3 ) ) );
    926922        $json = wp_json_encode( $data, 0, 1 );
  • trunk/tests/phpunit/tests/post/query.php

    r44701 r46214  
    706706     */
    707707    public function test_set_found_posts_not_posts_as_an_array( $posts, $expected ) {
    708         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    709             $this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' );
    710             return;
    711         }
    712 
    713708        $q = new WP_Query(
    714709            array(
  • trunk/tests/phpunit/tests/rest-api/rest-request.php

    r45607 r46214  
    492492
    493493    public function test_has_valid_params_json_error() {
    494         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    495             return $this->markTestSkipped( 'JSON validation is only available for PHP 5.3+' );
    496         }
    497 
    498494        $this->request->set_header( 'Content-Type', 'application/json' );
    499495        $this->request->set_body( '{"invalid": JSON}' );
     
    508504
    509505    public function test_has_valid_params_empty_json_no_error() {
    510         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    511             return $this->markTestSkipped( 'JSON validation is only available for PHP 5.3+' );
    512         }
    513 
    514506        $this->request->set_header( 'Content-Type', 'application/json' );
    515507        $this->request->set_body( '' );
  • trunk/tests/phpunit/tests/theme/customHeader.php

    r43571 r46214  
    127127        $this->assertEmpty( $html );
    128128
    129         // ReflectionMethod::setAccessible is only available in PHP 5.3+
    130         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    131             return;
    132         }
    133129        // The container should always be returned in the Customizer preview.
    134130        $this->_set_customize_previewing( true );
     
    227223
    228224    function test_header_script_is_enqueued_by_the_custom_header_markup_without_video_when_previewing_in_customizer() {
    229         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    230             $this->markTestSkipped( 'ReflectionMethod::setAccessible is only available in PHP 5.3+' );
    231             return;
    232         }
    233 
    234225        $this->_add_theme_support(
    235226            array(
  • trunk/tests/phpunit/tests/widgets/media-widget.php

    r45103 r46214  
    480480     */
    481481    function test_has_content() {
    482         if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
    483             $this->markTestSkipped( 'ReflectionMethod::setAccessible is only available for PHP 5.3+' );
    484             return;
    485         }
    486 
    487482        $attachment_id = self::factory()->attachment->create_object(
    488483            array(
Note: See TracChangeset for help on using the changeset viewer.