Streams: Return early from wp_is_stream() for paths that aren't streams.

Some versions of PHP appear to have a memory leak that is occasionally triggered by calling `stream_get_wrappers()`. In order to avoid calling this, we can return early from `wp_is_stream()` when `$path` doesn't contain `://`.

Props pbiron, JPry, dontstealmyfish.
Fixes #44532.



git-svn-id: https://develop.svn.wordpress.org/trunk@43466 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2018-07-17 07:53:18 +00:00
parent 8c55028c90
commit 6c8c2aeaf9

View File

@ -5553,6 +5553,11 @@ function _device_can_upload() {
* @return bool True if the path is a stream URL.
*/
function wp_is_stream( $path ) {
if ( false === strpos( $path, '://' ) ) {
// $path isn't a stream
return false;
}
$wrappers = stream_get_wrappers();
$wrappers = array_map( 'preg_quote', $wrappers );
$wrappers_re = '(' . join( '|', $wrappers ) . ')';