From 6c8c2aeaf9201bb630946010f53d457b47f64116 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 17 Jul 2018 07:53:18 +0000 Subject: [PATCH] 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 --- src/wp-includes/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 8ae58299d6..2ed7a3d3f2 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -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 ) . ')';