WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 3 days ago

#47746 new defect (bug)

PHP 7.4 compatibility fix / implode argument order

Reported by: jrf Owned by:
Milestone: 5.3 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch php74
Focuses: coding-standards Cc:

Description

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:

Related:

Note: join() is an alias of implode(). It is generally considered best practice to use the canonical function rather than an alias, however, that is outside the scope of this ticket.

Attachments (2)

47746-fix-implode-argument-order.patch (3.4 KB) - added by jrf 2 months ago.
47746.diff (970 bytes) - added by jorbin 6 weeks ago.

Download all attachments as: .zip

Change History (7)

#1 @jrf
2 months ago

FYI: I have reviewed ALL function calls to implode() and join() to get at this patch. Based on the current trunk, there are no remaining issues.

#2 follow-up: @johnbillion
2 months ago

  • Version trunk deleted

The changes to Requests and Simplepie need to be made upstream to their respective repos.

The other two changes look good.

#3 in reply to: ↑ 2 @jrf
2 months ago

Replying to johnbillion:

The changes to Requests and Simplepie need to be made upstream to their respective repos.

The other two changes look good.

Pull requests to both upstream repos have already been opened (see links above), but neither is very actively maintained.

The Requests dependency in Core is at the latest version - 1.7 -, but that version was released in October 2016 (!!!).
Ref: https://github.com/rmccue/Requests/releases

The Requests repo has had no commits since December 2017 and only a few, mostly DevOps related ones since the last release.

The SimplePie dependency in Core is at version 1.3.1 - which was released in October 2012 😰, while the current version is 1.5.2 released in August 2018.
Ref: https://github.com/simplepie/simplepie/releases

And while the SimplePie repo has actually had some commits this year (February), the version used in WP Core is pretty far behind the latest release.

So, yes, while I agree that the fixes should primarily be made upstream, I don't think WP should be throwing deprecation notices when run on PHP 7.4 while we are waiting for
1) new releases from upstream and
2) the existing WP Core versions of those libraries to be updated.

@jorbin
6 weeks ago

#4 @jrf
6 weeks ago

  • Keywords php74 added

#5 @jrf
3 days ago

FYI:

The patch for Core looks good and should IMO be committed ASAP.

Note: See TracTickets for help on using tickets.