`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. Built from https://develop.svn.wordpress.org/trunk@54309 git-svn-id: http://core.svn.wordpress.org/trunk@53868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
254 KiB
254 KiB