From 4f856dfae04ef3fcd3e320f92db587e644ce6bfc Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 9 Feb 2022 12:33:05 +0000 Subject: [PATCH] Code Modernization: Use `stream_get_contents()` in `POMO_FileReader::read_all()`. `stream_get_contents()` is faster than `fread()`, because the PHP core can decide how to best read the remaining file; it could decide to issue just one `read()` call or `mmap()` the file first. Per the PHP manual, `file_get_contents()` or `stream_get_contents()` is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by the OS to enhance performance. Reference: [https://www.php.net/manual/en/function.file-get-contents.php PHP Manual: file_get_contents()]. Follow-up to [12174]. Props maxkellermann. See #55069. Built from https://develop.svn.wordpress.org/trunk@52696 git-svn-id: http://core.svn.wordpress.org/trunk@52285 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pomo/streams.php | 6 +----- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/wp-includes/pomo/streams.php b/wp-includes/pomo/streams.php index e95dc17076..6a971af065 100644 --- a/wp-includes/pomo/streams.php +++ b/wp-includes/pomo/streams.php @@ -217,11 +217,7 @@ if ( ! class_exists( 'POMO_FileReader', false ) ) : * @return string */ public function read_all() { - $all = ''; - while ( ! $this->feof() ) { - $all .= $this->read( 4096 ); - } - return $all; + return stream_get_contents( $this->_f ); } } endif; diff --git a/wp-includes/version.php b/wp-includes/version.php index 0343f7ee17..0351f05a50 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52695'; +$wp_version = '6.0-alpha-52696'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.