Make WordPress Core

Ticket #55069: 0003-functions.php-use-file_get_contents-in-get_file_data.2.patch

File 0003-functions.php-use-file_get_contents-in-get_file_data.2.patch, 1.2 KB (added by maxkellermann, 2 years ago)
  • src/wp-includes/functions.php

    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() { 
    65286528 * @return string[] Array of file header values keyed by header name.
    65296529 */
    65306530function 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 );
    65336533
    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 ) {
    65416535                $file_data = '';
    65426536        }
    65436537