WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 8 weeks ago

#48091 reviewing task (blessed)

Remove conditional use of PHP stream_get_contents()

Reported by: jrf Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version: 5.3
Component: General Keywords: has-patch
Focuses: performance, coding-standards Cc:
PR Number:

Description

While working on #48075 / looking for code which can be removed now support for PHP < 5.6.20 has been dropped, I came across three instances where checks were done for the existance of the stream_get_contents() function.

<?php
if ( function_exists( 'stream_get_contents' ) ) {
        // Code.
}

Now, there are only two reasons I can think for this code to exist:

  1. Support for PHP < 5.

The `stream_get_contents()` function was introduced in PHP 5.0.0. It might be that this code is from before that time.

  1. Hosts disabling the function using the `disabled_functions` ini directive.

I honestly don't know if that's a thing, but that's the only other reason I could think of for this code to exist.


Based on the comment found in the `class-wp-filesystem-ssh2.php` documentation, I strongly believe the reason is 1) and that the removal of these conditions is long overdue, if for no other reason than that the function is used unconditionally in the `mo.php` file.

So based on that I am attaching a patch to remove the condition.

Attachments (1)

48091-src-Remove-work-arounds-for-stream_get_contents.patch (2.3 KB) - added by jrf 3 months ago.
[src] Remove work-arounds for stream_get_contents()

Download all attachments as: .zip

Change History (2)

@jrf
3 months ago

[src] Remove work-arounds for stream_get_contents()

#1 @SergeyBiryukov
8 weeks ago

  • Milestone changed from Awaiting Review to 5.4
  • Status changed from assigned to reviewing
Note: See TracTickets for help on using tickets.