[wp-trac] [WordPress Trac] #51057: [PHP 8] PemFTP - Fix is_resource() calls on Socket class objects
WordPress Trac
noreply at wordpress.org
Tue Aug 18 21:10:18 UTC 2020
#51057: [PHP 8] PemFTP - Fix is_resource() calls on Socket class objects
--------------------------------+-----------------------------
Reporter: ayeshrajans | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: External Libraries | Version:
Severity: normal | Keywords: php8
Focuses: |
--------------------------------+-----------------------------
WordPress includes a library called PemFTP. The upstream appears to be
abandoned, and we have previously made patches in that library (#33432).
In PHP 8, `socket_*` functions return/accept `\Socket` class objects that
no longer returns true on `is_resource()` checks:
https://php.watch/versions/8.0/sockets-sockets-addressinfo
The simplest and backwards compatible approach is simply check `$fp !==
false` in place of `is_resource($fp)` calls. On all `sockets_*()`
functions that creates a `Socket` resource, `false` is returned in case
the operation fails, which makes the `is_resource()` call equivalent to
`!== false` in PHP < 8.0, and buggy in PHP >= 8.0.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51057>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list