mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Code Modernization: Use file_get_contents()
in wp_get_webp_info()
.
`file_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 [50810], [52696], [52698], [52701]. Props maxkellermann. See #55069. Built from https://develop.svn.wordpress.org/trunk@52718 git-svn-id: http://core.svn.wordpress.org/trunk@52307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c128cd263a
commit
1e1fb78c07
@ -5235,15 +5235,12 @@ function wp_get_webp_info( $filename ) {
|
||||
return compact( 'width', 'height', 'type' );
|
||||
}
|
||||
|
||||
$handle = fopen( $filename, 'rb' );
|
||||
$magic = file_get_contents( $filename, false, null, 0, 40 );
|
||||
|
||||
if ( false === $handle ) {
|
||||
if ( false === $magic ) {
|
||||
return compact( 'width', 'height', 'type' );
|
||||
}
|
||||
|
||||
$magic = fread( $handle, 40 );
|
||||
fclose( $handle );
|
||||
|
||||
// Make sure we got enough bytes.
|
||||
if ( strlen( $magic ) < 40 ) {
|
||||
return compact( 'width', 'height', 'type' );
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-alpha-52717';
|
||||
$wp_version = '6.0-alpha-52718';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user