Site Health: Improve fonts directory check.

This changeset enhances the filesystem checks in the Site Health debug data by addressing the following:
- Existence Check: Before checking if the fonts directory is writable, it first verifies whether the directory exists.
- Improved Messaging: If the fonts directory does not exist, the debug output now reflects this scenario as "Does not exist". If the directory exists, it shows whether it is writable or not.

Props zodiac1978, samiamnot, sainathpoojary, abcd95, ankitkumarshah, im3dabasia1.
Fixes #62633.



git-svn-id: https://develop.svn.wordpress.org/trunk@59853 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras 2025-02-21 14:50:17 +00:00
parent d9b9fa5dba
commit 1d77cfa438

View File

@ -1646,12 +1646,13 @@ class WP_Debug_Data {
*/
private static function get_wp_filesystem(): array {
$upload_dir = wp_upload_dir();
$fonts_dir_exists = file_exists( wp_get_font_dir()['basedir'] );
$is_writable_abspath = wp_is_writable( ABSPATH );
$is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR );
$is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] );
$is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR );
$is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );
$is_writable_fonts_dir = wp_is_writable( wp_get_font_dir()['basedir'] );
$is_writable_fonts_dir = $fonts_dir_exists ? wp_is_writable( wp_get_font_dir()['basedir'] ) : false;
$fields = array(
'wordpress' => array(
@ -1681,8 +1682,12 @@ class WP_Debug_Data {
),
'fonts' => array(
'label' => __( 'The fonts directory' ),
'value' => ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_fonts_dir ? 'writable' : 'not writable' ),
'value' => $fonts_dir_exists
? ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) )
: __( 'Does not exist' ),
'debug' => $fonts_dir_exists
? ( $is_writable_fonts_dir ? 'writable' : 'not writable' )
: 'does not exist',
),
);