WordPress.org

Make WordPress Core

Ticket #47746: 47746-fix-implode-argument-order.patch

File 47746-fix-implode-argument-order.patch, 3.4 KB (added by jrf, 17 months ago)
  • src/wp-admin/includes/ajax-actions.php

    From 21711592d0915687fb12209e0e1833f9b9eaad0d Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Sun, 21 Jul 2019 08:18:09 +0200
    Subject: [PATCH] PHP 7.4 compatibility fix / implode argument order
    
    `implode()` takes two parameters, `$glue` and `$pieces`.
    For historical reasons, `implode()` accepted these parameters in either order, though it was recommended to use the documented argument order of `implode( $glue, $pieces )`.
    
    PHP 7.4 is slated to deprecate the tolerance for passing the parameters for `implode()` in reverse order.
    PHP 8.0 is expected to remove the tolerance for this completely.
    
    Refs:
    * https://wiki.php.net/rfc/deprecations_php_7_4#implode_parameter_order_mix
    * https://php.net/manual/en/function.implode.php
    
    Related:
    * https://github.com/rmccue/Requests/pull/346
    * https://github.com/simplepie/simplepie/pull/617
    ---
     src/wp-admin/includes/ajax-actions.php           | 2 +-
     src/wp-admin/includes/upgrade.php                | 2 +-
     src/wp-includes/Requests/Transport/fsockopen.php | 2 +-
     src/wp-includes/SimplePie/Parse/Date.php         | 4 ++--
     4 files changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
    index d94bb928df..c2ee540434 100644
    a b function wp_ajax_ajax_tag_search() { 
    159159                )
    160160        );
    161161
    162         echo join( $results, "\n" );
     162        echo join( "\n", $results );
    163163        wp_die();
    164164}
    165165
  • src/wp-admin/includes/upgrade.php

    diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
    index 9a6847ba59..a8e4856fb8 100644
    a b function upgrade_130() { 
    10511051                        $limit    = $option->dupes - 1;
    10521052                        $dupe_ids = $wpdb->get_col( $wpdb->prepare( "SELECT option_id FROM $wpdb->options WHERE option_name = %s LIMIT %d", $option->option_name, $limit ) );
    10531053                        if ( $dupe_ids ) {
    1054                                 $dupe_ids = join( $dupe_ids, ',' );
     1054                                $dupe_ids = join( ',', $dupe_ids );
    10551055                                $wpdb->query( "DELETE FROM $wpdb->options WHERE option_id IN ($dupe_ids)" );
    10561056                        }
    10571057                }
  • src/wp-includes/Requests/Transport/fsockopen.php

    diff --git a/src/wp-includes/Requests/Transport/fsockopen.php b/src/wp-includes/Requests/Transport/fsockopen.php
    index 21cb56d5ec..aec1fdd493 100644
    a b class Requests_Transport_fsockopen implements Requests_Transport { 
    192192                $headers = Requests::flatten($headers);
    193193
    194194                if (!empty($headers)) {
    195                         $out .= implode($headers, "\r\n") . "\r\n";
     195                        $out .= implode( "\r\n", $headers ) . "\r\n";
    196196                }
    197197
    198198                $options['hooks']->dispatch('fsockopen.after_headers', array(&$out));
  • src/wp-includes/SimplePie/Parse/Date.php

    diff --git a/src/wp-includes/SimplePie/Parse/Date.php b/src/wp-includes/SimplePie/Parse/Date.php
    index 88e46e0309..52fea21efe 100644
    a b class SimplePie_Parse_Date 
    542542         */
    543543        public function __construct()
    544544        {
    545                 $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
    546                 $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
     545                $this->day_pcre = '(' . implode('|', array_keys($this->day)) . ')';
     546                $this->month_pcre = '(' . implode('|', array_keys($this->month)) . ')';
    547547
    548548                static $cache;
    549549                if (!isset($cache[get_class($this)]))