Changeset 55720 for trunk/src/wp-admin/includes/class-wp-site-health.php
- Timestamp:
- 05/04/2023 02:34:58 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-site-health.php
r55703 r55720 1927 1927 1928 1928 /** 1929 * Tests available disk space for updates. 1930 * 1931 * @since 6.3.0 1932 * 1933 * @return array The test results. 1934 */ 1935 public function get_test_available_updates_disk_space() { 1936 $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false; 1937 1938 $available_space = false !== $available_space 1939 ? (int) $available_space 1940 : 0; 1941 1942 $result = array( 1943 'label' => __( 'Disk space available to safely perform updates' ), 1944 'status' => 'good', 1945 'badge' => array( 1946 'label' => __( 'Security' ), 1947 'color' => 'blue', 1948 ), 1949 'description' => sprintf( 1950 /* translators: %s: Available disk space in MB or GB. */ 1951 '<p>' . __( '%s available disk space was detected, update routines can be performed safely.' ) . '</p>', 1952 size_format( $available_space ) 1953 ), 1954 'actions' => '', 1955 'test' => 'available_updates_disk_space', 1956 ); 1957 1958 if ( $available_space < 100 * MB_IN_BYTES ) { 1959 $result['description'] = __( 'Available disk space is low, less than 100 MB available.' ); 1960 $result['status'] = 'recommended'; 1961 } 1962 1963 if ( $available_space < 20 * MB_IN_BYTES ) { 1964 $result['description'] = __( 'Available disk space is critically low, less than 20 MB available. Proceed with caution, updates may fail.' ); 1965 $result['status'] = 'critical'; 1966 } 1967 1968 if ( ! $available_space ) { 1969 $result['description'] = __( 'Could not determine available disk space for updates.' ); 1970 $result['status'] = 'recommended'; 1971 } 1972 1973 return $result; 1974 } 1975 1976 /** 1977 * Tests if plugin and theme temporary backup directories are writable or can be created. 1978 * 1979 * @since 6.3.0 1980 * 1981 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass. 1982 * 1983 * @return array The test results. 1984 */ 1985 public function get_test_update_temp_backup_writable() { 1986 global $wp_filesystem; 1987 1988 $result = array( 1989 'label' => __( 'Plugin and theme temporary backup directory is writable' ), 1990 'status' => 'good', 1991 'badge' => array( 1992 'label' => __( 'Security' ), 1993 'color' => 'blue', 1994 ), 1995 'description' => sprintf( 1996 /* translators: %s: wp-content/upgrade-temp-backup */ 1997 '<p>' . __( 'The %s directory used to improve the stability of plugin and theme updates is writable.' ) . '</p>', 1998 '<code>wp-content/upgrade-temp-backup</code>' 1999 ), 2000 'actions' => '', 2001 'test' => 'update_temp_backup_writable', 2002 ); 2003 2004 if ( ! $wp_filesystem ) { 2005 require_once ABSPATH . '/wp-admin/includes/file.php'; 2006 WP_Filesystem(); 2007 } 2008 2009 $wp_content = $wp_filesystem->wp_content_dir(); 2010 2011 if ( ! $wp_content ) { 2012 $result['status'] = 'critical'; 2013 $result['label'] = sprintf( 2014 /* translators: %s: wp-content */ 2015 __( 'Unable to locate WordPress content directory (%s)' ), 2016 '<code>wp-content</code>' 2017 ); 2018 $result['description'] = sprintf( 2019 /* translators: %s: wp-content */ 2020 '<p>' . __( 'The %s directory cannot be located.' ) . '</p>', 2021 '<code>wp-content</code>' 2022 ); 2023 return $result; 2024 } 2025 2026 $upgrade_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade" ); 2027 $upgrade_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade" ); 2028 $backup_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup" ); 2029 $backup_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup" ); 2030 2031 $plugins_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup/plugins" ); 2032 $plugins_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup/plugins" ); 2033 $themes_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup/themes" ); 2034 $themes_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup/themes" ); 2035 2036 if ( $plugins_dir_exists && ! $plugins_dir_is_writable && $themes_dir_exists && ! $themes_dir_is_writable ) { 2037 $result['status'] = 'critical'; 2038 $result['label'] = __( 'Plugin and theme temporary backup directories exist but are not writable' ); 2039 $result['description'] = sprintf( 2040 /* translators: 1: wp-content/upgrade-temp-backup/plugins, 2: wp-content/upgrade-temp-backup/themes. */ 2041 '<p>' . __( 'The %1$s and %2$s directories exist but are not writable. These directories are used to improve the stability of plugin updates. Please make sure the server has write permissions to these directories.' ) . '</p>', 2042 '<code>wp-content/upgrade-temp-backup/plugins</code>', 2043 '<code>wp-content/upgrade-temp-backup/themes</code>' 2044 ); 2045 return $result; 2046 } 2047 2048 if ( $plugins_dir_exists && ! $plugins_dir_is_writable ) { 2049 $result['status'] = 'critical'; 2050 $result['label'] = __( 'Plugin temporary backup directory exists but is not writable' ); 2051 $result['description'] = sprintf( 2052 /* translators: %s: wp-content/upgrade-temp-backup/plugins */ 2053 '<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of plugin updates. Please make sure the server has write permissions to this directory.' ) . '</p>', 2054 '<code>wp-content/upgrade-temp-backup/plugins</code>' 2055 ); 2056 return $result; 2057 } 2058 2059 if ( $themes_dir_exists && ! $themes_dir_is_writable ) { 2060 $result['status'] = 'critical'; 2061 $result['label'] = __( 'Theme temporary backup directory exists but is not writable' ); 2062 $result['description'] = sprintf( 2063 /* translators: %s: wp-content/upgrade-temp-backup/themes */ 2064 '<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of theme updates. Please make sure the server has write permissions to this directory.' ) . '</p>', 2065 '<code>wp-content/upgrade-temp-backup/themes</code>' 2066 ); 2067 return $result; 2068 } 2069 2070 if ( ( ! $plugins_dir_exists || ! $themes_dir_exists ) && $backup_dir_exists && ! $backup_dir_is_writable ) { 2071 $result['status'] = 'critical'; 2072 $result['label'] = __( 'The temporary backup directory exists but is not writable' ); 2073 $result['description'] = sprintf( 2074 /* translators: %s: wp-content/upgrade-temp-backup */ 2075 '<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of plugin and theme updates. Please make sure the server has write permissions to this directory.' ) . '</p>', 2076 '<code>wp-content/upgrade-temp-backup</code>' 2077 ); 2078 return $result; 2079 } 2080 2081 if ( ! $backup_dir_exists && $upgrade_dir_exists && ! $upgrade_dir_is_writable ) { 2082 $result['status'] = 'critical'; 2083 $result['label'] = sprintf( 2084 /* translators: %s: upgrade */ 2085 __( 'The %s directory exists but is not writable' ), 2086 'upgrade' 2087 ); 2088 $result['description'] = sprintf( 2089 /* translators: %s: wp-content/upgrade */ 2090 '<p>' . __( 'The %s directory exists but is not writable. This directory is used for plugin and theme updates. Please make sure the server has write permissions to this directory.' ) . '</p>', 2091 '<code>wp-content/upgrade</code>' 2092 ); 2093 return $result; 2094 } 2095 2096 if ( ! $upgrade_dir_exists && ! $wp_filesystem->is_writable( $wp_content ) ) { 2097 $result['status'] = 'critical'; 2098 $result['label'] = sprintf( 2099 /* translators: %s: upgrade */ 2100 __( 'The %s directory cannot be created' ), 2101 'upgrade' 2102 ); 2103 $result['description'] = sprintf( 2104 /* translators: 1: wp-content/upgrade, 2: wp-content. */ 2105 '<p>' . __( 'The %1$s directory does not exist, and the server does not have write permissions in %2$s to create it. This directory is used for plugin and theme updates. Please make sure the server has write permissions in %2$s.' ) . '</p>', 2106 '<code>wp-content/upgrade</code>', 2107 '<code>wp-content</code>' 2108 ); 2109 return $result; 2110 } 2111 2112 return $result; 2113 } 2114 2115 /** 1929 2116 * Tests if loopbacks work as expected. 1930 2117 * … … 2533 2720 $tests = array( 2534 2721 'direct' => array( 2535 'wordpress_version' => array(2722 'wordpress_version' => array( 2536 2723 'label' => __( 'WordPress Version' ), 2537 2724 'test' => 'wordpress_version', 2538 2725 ), 2539 'plugin_version' => array(2726 'plugin_version' => array( 2540 2727 'label' => __( 'Plugin Versions' ), 2541 2728 'test' => 'plugin_version', 2542 2729 ), 2543 'theme_version' => array(2730 'theme_version' => array( 2544 2731 'label' => __( 'Theme Versions' ), 2545 2732 'test' => 'theme_version', 2546 2733 ), 2547 'php_version' => array(2734 'php_version' => array( 2548 2735 'label' => __( 'PHP Version' ), 2549 2736 'test' => 'php_version', 2550 2737 ), 2551 'php_extensions' => array(2738 'php_extensions' => array( 2552 2739 'label' => __( 'PHP Extensions' ), 2553 2740 'test' => 'php_extensions', 2554 2741 ), 2555 'php_default_timezone' => array(2742 'php_default_timezone' => array( 2556 2743 'label' => __( 'PHP Default Timezone' ), 2557 2744 'test' => 'php_default_timezone', 2558 2745 ), 2559 'php_sessions' => array(2746 'php_sessions' => array( 2560 2747 'label' => __( 'PHP Sessions' ), 2561 2748 'test' => 'php_sessions', 2562 2749 ), 2563 'sql_server' => array(2750 'sql_server' => array( 2564 2751 'label' => __( 'Database Server version' ), 2565 2752 'test' => 'sql_server', 2566 2753 ), 2567 'utf8mb4_support' => array(2754 'utf8mb4_support' => array( 2568 2755 'label' => __( 'MySQL utf8mb4 support' ), 2569 2756 'test' => 'utf8mb4_support', 2570 2757 ), 2571 'ssl_support' => array(2758 'ssl_support' => array( 2572 2759 'label' => __( 'Secure communication' ), 2573 2760 'test' => 'ssl_support', 2574 2761 ), 2575 'scheduled_events' => array(2762 'scheduled_events' => array( 2576 2763 'label' => __( 'Scheduled events' ), 2577 2764 'test' => 'scheduled_events', 2578 2765 ), 2579 'http_requests' => array(2766 'http_requests' => array( 2580 2767 'label' => __( 'HTTP Requests' ), 2581 2768 'test' => 'http_requests', 2582 2769 ), 2583 'rest_availability' => array(2770 'rest_availability' => array( 2584 2771 'label' => __( 'REST API availability' ), 2585 2772 'test' => 'rest_availability', 2586 2773 'skip_cron' => true, 2587 2774 ), 2588 'debug_enabled' => array(2775 'debug_enabled' => array( 2589 2776 'label' => __( 'Debugging enabled' ), 2590 2777 'test' => 'is_in_debug_mode', 2591 2778 ), 2592 'file_uploads' => array(2779 'file_uploads' => array( 2593 2780 'label' => __( 'File uploads' ), 2594 2781 'test' => 'file_uploads', 2595 2782 ), 2596 'plugin_theme_auto_updates' => array(2783 'plugin_theme_auto_updates' => array( 2597 2784 'label' => __( 'Plugin and theme auto-updates' ), 2598 2785 'test' => 'plugin_theme_auto_updates', 2786 ), 2787 'update_temp_backup_writable' => array( 2788 'label' => __( 'Plugin and theme temporary backup directory access' ), 2789 'test' => 'update_temp_backup_writable', 2790 ), 2791 'available_updates_disk_space' => array( 2792 'label' => __( 'Available disk space' ), 2793 'test' => 'available_updates_disk_space', 2599 2794 ), 2600 2795 ),
Note: See TracChangeset
for help on using the changeset viewer.