From eb543a161c1cbd4ea86377056b2fc0244405c2f7 Mon Sep 17 00:00:00 2001
From: Max Kellermann <mk@cm4all.com>
Date: Fri, 4 Feb 2022 16:36:21 +0100
Subject: [PATCH 3/5] functions.php: use file_get_contents() in get_file_data()
---
src/wp-includes/functions.php | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 667049aa3f..7b1efa3a33 100644
a
|
b
|
function wp_scheduled_delete() { |
6528 | 6528 | * @return string[] Array of file header values keyed by header name. |
6529 | 6529 | */ |
6530 | 6530 | function get_file_data( $file, $default_headers, $context = '' ) { |
6531 | | // We don't need to write to the file, so just open for reading. |
6532 | | $fp = fopen( $file, 'r' ); |
| 6531 | // Pull only the first 8 KB of the file in. |
| 6532 | $file_data = file_get_contents( $file, false, null, 0, 8192 ); |
6533 | 6533 | |
6534 | | if ( $fp ) { |
6535 | | // Pull only the first 8 KB of the file in. |
6536 | | $file_data = fread( $fp, 8 * KB_IN_BYTES ); |
6537 | | |
6538 | | // PHP will close file handle, but we are good citizens. |
6539 | | fclose( $fp ); |
6540 | | } else { |
| 6534 | if ( false === $file_data ) { |
6541 | 6535 | $file_data = ''; |
6542 | 6536 | } |
6543 | 6537 | |