#51057 closed defect (bug) (invalid)
[PHP 8] PemFTP - Fix is_resource() calls on Socket class objects
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | External Libraries | Keywords: | php8 |
Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (6)
#1
@
3 years ago
- Milestone changed from Awaiting Review to 5.6
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
3 years ago
#4
@
3 years ago
- Keywords close added
- Resolution set to worksforme
- Status changed from reviewing to closed
Thanks for your review @SergeyBiryukov - It indeed turns out that is_resource() is called on file resources only (which will be moved to objects eventually, but nothing to worry for now).
Sorry for wasting your time, and I appreciate your review either way 👍🏼.
Hmm, haven't tested it yet, but as far as I can see looking at the code, the
$fp
variable here is a file handle created withfopen()
, not with any of thesocket_*()
functions. So it seems likeis_resource()
checks should still work?