Commit 8e83aec
committed
General: Remove
`realpath()` already checks if the file exists, and returns `false` on failure. The additional `file_exists()` check is not necessary and can be removed, improving the performance.
This commit simplifies the checks in two functions:
* `register_block_type_from_metadata()`
* `wp_json_file_decode()`
Note: In both of these cases, the values are passed through `wp_normalize_path()` after `realpath()`, so if the file does not exist, the `false` value gets converted to an empty string. The updated checks work both for `false` and `''` values.
Though this is a small tweak, it saves a lot of checks since one of the places we do this is when registering block styles, so it runs quite a few times on each page load.
Reference: [https://www.php.net/manual/en/function.realpath.php PHP Manual: realpath()].
Follow-up to [51599], [54132], [54290], [54291].
Props aristath.
Fixes #56654.
git-svn-id: https://develop.svn.wordpress.org/trunk@54309 602fd350-edb4-49c9-b593-d223f7449a82file_exists() checks after calling realpath().1 parent 9fb661c commit 8e83aec
2 files changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
| 445 | + | |
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4528 | 4528 | | |
4529 | 4529 | | |
4530 | 4530 | | |
4531 | | - | |
| 4531 | + | |
| 4532 | + | |
4532 | 4533 | | |
4533 | 4534 | | |
4534 | 4535 | | |
| |||
0 commit comments