[wp-trac] [WordPress Trac] #49412: Store filesize media metadata

WordPress Trac noreply at wordpress.org
Tue May 3 07:12:47 UTC 2022


#49412: Store filesize media metadata
--------------------------------+---------------------------
 Reporter:  Cybr                |       Owner:  spacedmonkey
     Type:  feature request     |      Status:  reopened
 Priority:  normal              |   Milestone:  6.0
Component:  Media               |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  has-dev-note close  |     Focuses:  performance
--------------------------------+---------------------------

Comment (by Cybr):

 `filesize()` generates an `E_WARNING` in case of an error
 [https://www.php.net/manual/en/function.filesize.php (source)]. The `@`
 operator would suppress that. I see that operator is primarily used when
 handling files in WP; whether or not justified is concerned in #24780, as
 mentioned in comment:55.

 If we agree not using the Error Suppression operator, it'd be better to
 use
 `$size = file_exists( $path ) ? (int) filesize( $path ) : 0;`
 Casting to `(int)` is still required because PHP returns `false` on error,
 for whatever reason that might happen.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49412#comment:61>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list