WordPress.org

Make WordPress Core

Opened 4 weeks ago

#48091 assigned task (blessed)

Remove conditional use of PHP stream_get_contents()

Reported by: jrf Owned by: SergeyBiryukov
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
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 4 weeks ago.
[src] Remove work-arounds for stream_get_contents()

Download all attachments as: .zip

Change History (1)

@jrf
4 weeks ago

[src] Remove work-arounds for stream_get_contents()

Note: See TracTickets for help on using tickets.