Make WordPress Core

Ticket #46152: 46152.2.diff

File 46152.2.diff, 21.3 KB (added by desrosj, 5 years ago)
  • .travis.yml

     
    2929    name: PHP Linting
    3030  - env: WP_TRAVISCI=travis:js WP_INSTALL=false
    3131    name: JS Tests
     32  - env: WP_TRAVISCI=test:compat COMPOSER_INSTALL=true NPM_INSTALL=false WP_INSTALL=false
     33    name: "PHP Compatibility Checker"
    3234  - env: LOCAL_PHP=7.3-fpm WP_TRAVISCI=test:php
    3335    name: "PHPUnit Tests: PHP 7.3"
    3436  - env: LOCAL_PHP=7.3-fpm LOCAL_PHP_MEMCACHED=true WP_TRAVISCI=test:php
     
    4648  - env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php
    4749    name: "PHPUnit Tests: PHP 8.0"
    4850  allow_failures:
     51  - env: WP_TRAVISCI=test:compat COMPOSER_INSTALL=true NPM_INSTALL=false WP_INSTALL=false
    4952  - env: LOCAL_PHP=7.4-fpm WP_TRAVISCI=test:php
    5053  - env: LOCAL_PHP=8.0-fpm WP_TRAVISCI=test:php
    5154  fast_finish: true
     
    7578    npm ci
    7679  fi
    7780- |
    78   if [[ "$WP_TRAVISCI" == "test:e2e" ]] || [[ "$WP_TRAVISCI" == "test:php" ]]; then
     81  if [[ "$WP_TRAVISCI" == "test:e2e" ]] || [[ "$WP_TRAVISCI" == "test:php" ]] || [[ "$WP_TRAVISCI" == "test:compat" ]]; then
    7982    npm run env:start
    8083    npm run build
    8184    docker-compose run --rm mysql mysql --version
     
    120123      docker-compose run --rm php composer format &&
    121124      docker-compose run --rm php composer lint:errors &&
    122125      docker-compose run --rm php composer lint tests
     126    elif [[ "$WP_TRAVISCI" == "test:compat" ]]; then
     127      docker-compose run --rm php composer compat
    123128    else
    124129      npm run grunt $WP_TRAVISCI
    125130    fi
  • composer.json

     
    1111        },
    1212        "require-dev": {
    1313                "dealerdirect/phpcodesniffer-composer-installer": "~0.5.0",
    14                 "wp-coding-standards/wpcs": "~2.1.0"
     14                "wp-coding-standards/wpcs": "~2.1.0",
     15                "phpcompatibility/phpcompatibility-wp": "^2.1.0"
    1516        },
    1617        "scripts": {
     18                "compat": "phpcs --standard=phpcompat.xml.dist --report=summary,source --cache -d memory_limit=256M",
    1719                "format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source --cache -d memory_limit=256M",
    1820                "lint": "phpcs --standard=phpcs.xml.dist --report-summary --report-source --cache -d memory_limit=256M",
    1921                "lint:errors": "phpcs --standard=phpcs.xml.dist --report-summary --report-source --cache -d memory_limit=256M -n"
  • composer.lock

     
    44        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
    55        "This file is @generated automatically"
    66    ],
    7     "content-hash": "54fbee5534d4ee1d332bb374c5442e79",
     7    "content-hash": "b5c8f132394efcf7649e6e1fc4ac6143",
    88    "packages": [],
    99    "packages-dev": [
    1010        {
     
    7474            "time": "2018-10-26T13:21:45+00:00"
    7575        },
    7676        {
     77            "name": "phpcompatibility/php-compatibility",
     78            "version": "9.3.1",
     79            "source": {
     80                "type": "git",
     81                "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
     82                "reference": "9999344e47e7af6b00e1a898eacc4e4368fb7196"
     83            },
     84            "dist": {
     85                "type": "zip",
     86                "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9999344e47e7af6b00e1a898eacc4e4368fb7196",
     87                "reference": "9999344e47e7af6b00e1a898eacc4e4368fb7196",
     88                "shasum": ""
     89            },
     90            "require": {
     91                "php": ">=5.3",
     92                "squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
     93            },
     94            "conflict": {
     95                "squizlabs/php_codesniffer": "2.6.2"
     96            },
     97            "require-dev": {
     98                "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
     99            },
     100            "suggest": {
     101                "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
     102                "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
     103            },
     104            "type": "phpcodesniffer-standard",
     105            "notification-url": "https://packagist.org/downloads/",
     106            "license": [
     107                "LGPL-3.0-or-later"
     108            ],
     109            "authors": [
     110                {
     111                    "name": "Wim Godden",
     112                    "homepage": "https://github.com/wimg",
     113                    "role": "lead"
     114                },
     115                {
     116                    "name": "Juliette Reinders Folmer",
     117                    "homepage": "https://github.com/jrfnl",
     118                    "role": "lead"
     119                },
     120                {
     121                    "name": "Contributors",
     122                    "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
     123                }
     124            ],
     125            "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
     126            "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
     127            "keywords": [
     128                "compatibility",
     129                "phpcs",
     130                "standards"
     131            ],
     132            "time": "2019-09-05T18:36:49+00:00"
     133        },
     134        {
     135            "name": "phpcompatibility/phpcompatibility-paragonie",
     136            "version": "1.1.0",
     137            "source": {
     138                "type": "git",
     139                "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git",
     140                "reference": "b1bb79a7cab1fb856b56f1b5cf110b6e52d8e936"
     141            },
     142            "dist": {
     143                "type": "zip",
     144                "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/b1bb79a7cab1fb856b56f1b5cf110b6e52d8e936",
     145                "reference": "b1bb79a7cab1fb856b56f1b5cf110b6e52d8e936",
     146                "shasum": ""
     147            },
     148            "require": {
     149                "phpcompatibility/php-compatibility": "^9.0"
     150            },
     151            "require-dev": {
     152                "dealerdirect/phpcodesniffer-composer-installer": "^0.5",
     153                "paragonie/random_compat": "dev-master",
     154                "paragonie/sodium_compat": "dev-master"
     155            },
     156            "suggest": {
     157                "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
     158                "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
     159            },
     160            "type": "phpcodesniffer-standard",
     161            "notification-url": "https://packagist.org/downloads/",
     162            "license": [
     163                "LGPL-3.0-or-later"
     164            ],
     165            "authors": [
     166                {
     167                    "name": "Wim Godden",
     168                    "role": "lead"
     169                },
     170                {
     171                    "name": "Juliette Reinders Folmer",
     172                    "role": "lead"
     173                }
     174            ],
     175            "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.",
     176            "homepage": "http://phpcompatibility.com/",
     177            "keywords": [
     178                "compatibility",
     179                "paragonie",
     180                "phpcs",
     181                "polyfill",
     182                "standards"
     183            ],
     184            "time": "2019-08-28T15:58:19+00:00"
     185        },
     186        {
     187            "name": "phpcompatibility/phpcompatibility-wp",
     188            "version": "2.1.0",
     189            "source": {
     190                "type": "git",
     191                "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git",
     192                "reference": "41bef18ba688af638b7310666db28e1ea9158b2f"
     193            },
     194            "dist": {
     195                "type": "zip",
     196                "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/41bef18ba688af638b7310666db28e1ea9158b2f",
     197                "reference": "41bef18ba688af638b7310666db28e1ea9158b2f",
     198                "shasum": ""
     199            },
     200            "require": {
     201                "phpcompatibility/php-compatibility": "^9.0",
     202                "phpcompatibility/phpcompatibility-paragonie": "^1.0"
     203            },
     204            "require-dev": {
     205                "dealerdirect/phpcodesniffer-composer-installer": "^0.5"
     206            },
     207            "suggest": {
     208                "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.",
     209                "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
     210            },
     211            "type": "phpcodesniffer-standard",
     212            "notification-url": "https://packagist.org/downloads/",
     213            "license": [
     214                "LGPL-3.0-or-later"
     215            ],
     216            "authors": [
     217                {
     218                    "name": "Wim Godden",
     219                    "role": "lead"
     220                },
     221                {
     222                    "name": "Juliette Reinders Folmer",
     223                    "role": "lead"
     224                }
     225            ],
     226            "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.",
     227            "homepage": "http://phpcompatibility.com/",
     228            "keywords": [
     229                "compatibility",
     230                "phpcs",
     231                "standards",
     232                "wordpress"
     233            ],
     234            "time": "2019-08-28T14:22:28+00:00"
     235        },
     236        {
    77237            "name": "squizlabs/php_codesniffer",
    78238            "version": "3.4.0",
    79239            "source": {
  • phpcompat.xml.dist

     
     1<?xml version="1.0"?>
     2<ruleset name="WordPress PHP Compatibility">
     3        <description>Apply PHP compatibility checks to all Core files</description>
     4
     5        <rule ref="PHPCompatibilityWP"/>
     6        <config name="testVersion" value="5.6-7.4"/>
     7
     8        <arg name="extensions" value="php"/>
     9
     10        <!-- Strip the filepaths down to the relevant bit. -->
     11        <arg name="basepath" value="./"/>
     12
     13        <!-- Check up to 20 files simultaneously. -->
     14        <arg name="parallel" value="20"/>
     15
     16        <!-- Show sniff codes in all reports -->
     17        <arg value="ps"/>
     18
     19        <file>./src/</file>
     20
     21        <!-- Code which doesn't go into production may have different requirements. -->
     22        <exclude-pattern>/node_modules/*</exclude-pattern>
     23        <exclude-pattern>/vendor/*</exclude-pattern>
     24
     25        <!-- Compatibility libraries, deprecated external libraries, and polyfill exclusions -->
     26        <exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
     27        <exclude-pattern>/src/wp-includes/random_compat/*</exclude-pattern>
     28
     29        <!-- Whitelist the WP DB Class for use of `mysql_` extension in PHP < 7.0. -->
     30        <rule ref="PHPCompatibility.Extensions.RemovedExtensions">
     31                <exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
     32        </rule>
     33</ruleset>
  • src/wp-admin/includes/class-wp-debug-data.php

     
    728728                if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
    729729                        $client_version = $wpdb->dbh->client_info;
    730730                } else {
    731                         // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info
     731                        // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
    732732                        if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
    733733                                $client_version = $matches[0];
    734734                        } else {
  • src/wp-admin/includes/class-wp-site-health.php

     
    136136                        // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info
    137137                        $mysql_server_type = mysqli_get_server_info( $wpdb->dbh );
    138138                } else {
    139                         // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info
     139                        // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
    140140                        $mysql_server_type = mysql_get_server_info( $wpdb->dbh );
    141141                }
    142142
     
    10941094                        // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
    10951095                        $mysql_client_version = mysqli_get_client_info();
    10961096                } else {
    1097                         // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info
     1097                        // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
    10981098                        $mysql_client_version = mysql_get_client_info();
    10991099                }
    11001100
  • src/wp-admin/includes/file.php

     
    12201220                        ),
    12211221                        array(
    12221222                                'php'    => phpversion(),
     1223                                // phpcs:ignore PHPCompatibility.Constants.NewConstants.sodium_library_versionFound
    12231224                                'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
    12241225                        )
    12251226                );
     
    12531254                                ),
    12541255                                array(
    12551256                                        'php'                => phpversion(),
     1257                                        // phpcs:ignore PHPCompatibility.Constants.NewConstants.sodium_library_versionFound
    12561258                                        'sodium'             => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
    12571259                                        'polyfill_is_fast'   => false,
    12581260                                        'max_execution_time' => ini_get( 'max_execution_time' ),
     
    13261328                        'skipped_key' => $skipped_key,
    13271329                        'skipped_sig' => $skipped_signature,
    13281330                        'php'         => phpversion(),
     1331                        // phpcs:ignore PHPCompatibility.Constants.NewConstants.sodium_library_versionFound
    13291332                        'sodium'      => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ),
    13301333                )
    13311334        );
  • src/wp-admin/includes/upgrade.php

     
    24782478 * @param string $setting Option name.
    24792479 * @return mixed
    24802480 */
    2481 function __get_option( $setting ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     2481function __get_option( $setting ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    24822482        global $wpdb;
    24832483
    24842484        if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
  • src/wp-includes/author-template.php

     
    565565 * @since 3.2.0
    566566 * @access private
    567567 */
    568 function __clear_multi_author_cache() { //phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     568function __clear_multi_author_cache() { //phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    569569        delete_transient( 'is_multi_author' );
    570570}
  • src/wp-includes/deprecated.php

     
    17981798 * @deprecated 2.8.0 Use _n()
    17991799 * @see _n()
    18001800 */
    1801 function __ngettext( ...$args ) {
     1801function __ngettext( ...$args ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    18021802        _deprecated_function( __FUNCTION__, '2.8.0', '_n()' );
    18031803        return _n( ...$args );
    18041804}
     
    18101810 * @deprecated 2.8.0 Use _n_noop()
    18111811 * @see _n_noop()
    18121812 */
    1813 function __ngettext_noop( ...$args ) {
     1813function __ngettext_noop( ...$args ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    18141814        _deprecated_function( __FUNCTION__, '2.8.0', '_n_noop()' );
    18151815        return _n_noop( ...$args );
    18161816
     
    25122512 * Determines whether the current admin page is generated by a plugin.
    25132513 *
    25142514 * Use global $plugin_page and/or get_plugin_page_hookname() hooks.
    2515  * 
     2515 *
    25162516 * For more information on this and similar theme functions, check out
    2517  * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
     2517 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
    25182518 * Conditional Tags} article in the Theme Developer Handbook.
    2519  * 
     2519 *
    25202520 * @since 1.5.0
    25212521 * @deprecated 3.1.0
    25222522 *
     
    37193719
    37203720/**
    37213721 * Determines whether the current URL is within the comments popup window.
    3722  * 
     3722 *
    37233723 * For more information on this and similar theme functions, check out
    3724  * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
     3724 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
    37253725 * Conditional Tags} article in the Theme Developer Handbook.
    3726  * 
     3726 *
    37273727 * @since 1.5.0
    37283728 * @deprecated 4.5.0
    37293729 *
  • src/wp-includes/functions.php

     
    57635763 *
    57645764 * @return true True.
    57655765 */
    5766 function __return_true() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     5766function __return_true() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    57675767        return true;
    57685768}
    57695769
     
    57785778 *
    57795779 * @return false False.
    57805780 */
    5781 function __return_false() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     5781function __return_false() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    57825782        return false;
    57835783}
    57845784
     
    57915791 *
    57925792 * @return int 0.
    57935793 */
    5794 function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     5794function __return_zero() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    57955795        return 0;
    57965796}
    57975797
     
    58045804 *
    58055805 * @return array Empty array.
    58065806 */
    5807 function __return_empty_array() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     5807function __return_empty_array() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    58085808        return array();
    58095809}
    58105810
     
    58175817 *
    58185818 * @return null Null value.
    58195819 */
    5820 function __return_null() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     5820function __return_null() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    58215821        return null;
    58225822}
    58235823
     
    58325832 *
    58335833 * @return string Empty string.
    58345834 */
    5835 function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     5835function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    58365836        return '';
    58375837}
    58385838
  • src/wp-includes/general-template.php

     
    46834683 * @param string $type    The type of checked|selected|disabled|readonly we are doing
    46844684 * @return string html attribute or empty string
    46854685 */
    4686 function __checked_selected_helper( $helper, $current, $echo, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore
     4686function __checked_selected_helper( $helper, $current, $echo, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
    46874687        if ( (string) $helper === (string) $current ) {
    46884688                $result = " $type='$type'";
    46894689        } else {