[wp-trac] [WordPress Trac] #55678: Avoid `filesize()` warnings when storing file size in media metadata
WordPress Trac
noreply at wordpress.org
Thu May 5 00:16:31 UTC 2022
#55678: Avoid `filesize()` warnings when storing file size in media metadata
--------------------------+---------------------
Reporter: johnbillion | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.0
Component: Media | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+---------------------
Comment (by ironprogrammer):
Thank you for the patch, @antpb!
== Test Report
[https://core.trac.wordpress.org/attachment/ticket/55678/55678-1.diff
55678-1.diff] (and
[https://core.trac.wordpress.org/attachment/ticket/55678/55678.2.diff
55678.2.diff] 😂)
To clarify, this test does not confirm the existence of a defect prior to
patching, but rather validates consistent logging behavior expected after
the patch is applied.
=== Environment
* WordPress 6.0-RC1-53341-src
* macOS 12.3.1 (Monterey)
* In wp-config.php:Â `define( 'WP_DEBUG_LOG', true );`
* [https://wp-cli.org `wp-cli`] is installed
=== Steps to Reproduce
1. From a Terminal window, navigate to the WordPress root directory and
run: `wp shell`
2. At the `wp>` prompt, enter: `$size = wp_filesize( 'file-not-exist.php'
);` (assuming that this path is ''not'' an actual file).
3. ✅ Observe that the `wp-cli` shell returns `int(0)` and that no
`E_WARNING` message has been generated in the debug log. ''This confirms
use of error suppression using `@filesize()` from #49412.''
4. At the `wp>` prompt run `exit` to return to the command line shell.
=== Steps to Test Patch
1. 🛠Apply patch.
2. Repeat Steps 1-2 above.
3. ✅ Observe that the `wp-cli` shell returns `int(0)` and that no
`E_WARNING` message has been generated in the debug log. ''This confirms
mitigation of a `filesize()` error message without using the error
suppression operator, but by utilizing an `is_readable()` check in the new
patch.''
4. Repeat Step 4 above.
=== Expected Results
- The logging behavior before the patch was reproduced/confirmed
successfully. ✅
- The patch retains the expected logging behavior (i.e. no `E_WARNING`
logged). ✅
=== Additional Notes
- Unit tests for `wp_filesize()` were included in #49412.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55678#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list