From 2bda4cf819ba20181a30892c5ca7fb29abd9ff52 Mon Sep 17 00:00:00 2001
From: Max Kellermann <mk@cm4all.com>
Date: Fri, 4 Feb 2022 16:42:21 +0100
Subject: [PATCH 4/5] functions.php: use file_get_contents() in
 wp_get_image_mime()

---
 src/wp-includes/functions.php | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index f0349490f1..32034d26df 100644
--- a/src/wp-includes/functions.php
+++ b/src/wp-includes/functions.php
@@ -3227,12 +3227,7 @@ function wp_get_image_mime( $file ) {
 			return $mime;
 		}
 
-		$handle = fopen( $file, 'rb' );
-		if ( false === $handle ) {
-			return false;
-		}
-
-		$magic = fread( $handle, 12 );
+		$magic = file_get_contents( $file, false, null, 0, 12 );
 		if ( false === $magic ) {
 			return false;
 		}
@@ -3251,8 +3246,6 @@ function wp_get_image_mime( $file ) {
 		) {
 			$mime = 'image/webp';
 		}
-
-		fclose( $handle );
 	} catch ( Exception $e ) {
 		$mime = false;
 	}
-- 
2.34.0

