Changeset 59002
- Timestamp:
- 09/10/2024 12:02:08 AM (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-debug-data.php
r58996 r59002 86 86 'wp-plugins-inactive' => array(), 87 87 'wp-media' => array(), 88 'wp-server' => array(),88 'wp-server' => self::get_wp_server(), 89 89 'wp-database' => self::get_wp_database(), 90 90 'wp-constants' => self::get_wp_constants(), 91 91 'wp-filesystem' => self::get_wp_filesystem(), 92 92 ); 93 94 // Remove debug data which is only relevant on single-site installs. 95 if ( is_multisite() ) { 96 unset( $info['wp-paths-sizes'] ); 97 } 93 98 94 99 $info['wp-core'] = array( … … 215 220 $info['wp-media'] = array( 216 221 'label' => __( 'Media Handling' ), 217 'fields' => array(),218 );219 220 $info['wp-server'] = array(221 'label' => __( 'Server' ),222 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.' ),223 'fields' => array(),224 );225 226 $info['wp-database'] = array(227 'label' => __( 'Database' ),228 222 'fields' => array(), 229 223 ); … … 545 539 'value' => $gs, 546 540 'debug' => $gs_debug, 547 );548 549 // Populate the server debug fields.550 if ( function_exists( 'php_uname' ) ) {551 $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );552 } else {553 $server_architecture = 'unknown';554 }555 556 $php_version_debug = PHP_VERSION;557 // Whether PHP supports 64-bit.558 $php64bit = ( PHP_INT_SIZE * 8 === 64 );559 560 $php_version = sprintf(561 '%s %s',562 $php_version_debug,563 ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )564 );565 566 if ( $php64bit ) {567 $php_version_debug .= ' 64bit';568 }569 570 $info['wp-server']['fields']['server_architecture'] = array(571 'label' => __( 'Server architecture' ),572 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),573 'debug' => $server_architecture,574 );575 $info['wp-server']['fields']['httpd_software'] = array(576 'label' => __( 'Web server' ),577 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),578 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),579 );580 $info['wp-server']['fields']['php_version'] = array(581 'label' => __( 'PHP version' ),582 'value' => $php_version,583 'debug' => $php_version_debug,584 );585 $info['wp-server']['fields']['php_sapi'] = array(586 'label' => __( 'PHP SAPI' ),587 'value' => PHP_SAPI,588 'debug' => PHP_SAPI,589 );590 591 // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.592 if ( ! function_exists( 'ini_get' ) ) {593 $info['wp-server']['fields']['ini_get'] = array(594 'label' => __( 'Server settings' ),595 'value' => sprintf(596 /* translators: %s: ini_get() */597 __( 'Unable to determine some settings, as the %s function has been disabled.' ),598 'ini_get()'599 ),600 'debug' => 'ini_get() is disabled',601 );602 } else {603 $info['wp-server']['fields']['max_input_variables'] = array(604 'label' => __( 'PHP max input variables' ),605 'value' => ini_get( 'max_input_vars' ),606 );607 $info['wp-server']['fields']['time_limit'] = array(608 'label' => __( 'PHP time limit' ),609 'value' => ini_get( 'max_execution_time' ),610 );611 612 if ( WP_Site_Health::get_instance()->php_memory_limit !== ini_get( 'memory_limit' ) ) {613 $info['wp-server']['fields']['memory_limit'] = array(614 'label' => __( 'PHP memory limit' ),615 'value' => WP_Site_Health::get_instance()->php_memory_limit,616 );617 $info['wp-server']['fields']['admin_memory_limit'] = array(618 'label' => __( 'PHP memory limit (only for admin screens)' ),619 'value' => ini_get( 'memory_limit' ),620 );621 } else {622 $info['wp-server']['fields']['memory_limit'] = array(623 'label' => __( 'PHP memory limit' ),624 'value' => ini_get( 'memory_limit' ),625 );626 }627 628 $info['wp-server']['fields']['max_input_time'] = array(629 'label' => __( 'Max input time' ),630 'value' => ini_get( 'max_input_time' ),631 );632 $info['wp-server']['fields']['upload_max_filesize'] = array(633 'label' => __( 'Upload max filesize' ),634 'value' => ini_get( 'upload_max_filesize' ),635 );636 $info['wp-server']['fields']['php_post_max_size'] = array(637 'label' => __( 'PHP post max size' ),638 'value' => ini_get( 'post_max_size' ),639 );640 }641 642 if ( function_exists( 'curl_version' ) ) {643 $curl = curl_version();644 645 $info['wp-server']['fields']['curl_version'] = array(646 'label' => __( 'cURL version' ),647 'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),648 );649 } else {650 $info['wp-server']['fields']['curl_version'] = array(651 'label' => __( 'cURL version' ),652 'value' => $not_available,653 'debug' => 'not available',654 );655 }656 657 // SUHOSIN.658 $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );659 660 $info['wp-server']['fields']['suhosin'] = array(661 'label' => __( 'Is SUHOSIN installed?' ),662 'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ),663 'debug' => $suhosin_loaded,664 );665 666 // Imagick.667 $imagick_loaded = extension_loaded( 'imagick' );668 669 $info['wp-server']['fields']['imagick_availability'] = array(670 'label' => __( 'Is the Imagick library available?' ),671 'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ),672 'debug' => $imagick_loaded,673 );674 675 // Pretty permalinks.676 $pretty_permalinks_supported = got_url_rewrite();677 678 $info['wp-server']['fields']['pretty_permalinks'] = array(679 'label' => __( 'Are pretty permalinks supported?' ),680 'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ),681 'debug' => $pretty_permalinks_supported,682 );683 684 // Check if a .htaccess file exists.685 if ( is_file( ABSPATH . '.htaccess' ) ) {686 // If the file exists, grab the content of it.687 $htaccess_content = file_get_contents( ABSPATH . '.htaccess' );688 689 // Filter away the core WordPress rules.690 $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );691 $filtered_htaccess_content = ! empty( $filtered_htaccess_content );692 693 if ( $filtered_htaccess_content ) {694 /* translators: %s: .htaccess */695 $htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' );696 } else {697 /* translators: %s: .htaccess */698 $htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' );699 }700 701 $info['wp-server']['fields']['htaccess_extra_rules'] = array(702 'label' => __( '.htaccess rules' ),703 'value' => $htaccess_rules_string,704 'debug' => $filtered_htaccess_content,705 );706 }707 708 // Server time.709 $date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );710 711 $info['wp-server']['fields']['current'] = array(712 'label' => __( 'Current time' ),713 'value' => $date->format( DateTime::ATOM ),714 );715 $info['wp-server']['fields']['utc-time'] = array(716 'label' => __( 'Current UTC time' ),717 'value' => $date->format( DateTime::RFC850 ),718 );719 $info['wp-server']['fields']['server-time'] = array(720 'label' => __( 'Current Server time' ),721 'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ),722 541 ); 723 542 … … 1248 1067 1249 1068 /** 1069 * Gets the WordPress server section of the debug data. 1070 * 1071 * @since 6.7.0 1072 * 1073 * @return array 1074 */ 1075 public static function get_wp_server(): array { 1076 // Populate the server debug fields. 1077 if ( function_exists( 'php_uname' ) ) { 1078 $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) ); 1079 } else { 1080 $server_architecture = 'unknown'; 1081 } 1082 1083 $php_version_debug = PHP_VERSION; 1084 // Whether PHP supports 64-bit. 1085 $php64bit = ( PHP_INT_SIZE * 8 === 64 ); 1086 1087 $php_version = sprintf( 1088 '%s %s', 1089 $php_version_debug, 1090 ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) ) 1091 ); 1092 1093 if ( $php64bit ) { 1094 $php_version_debug .= ' 64bit'; 1095 } 1096 1097 $fields = array(); 1098 1099 $fields['server_architecture'] = array( 1100 'label' => __( 'Server architecture' ), 1101 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ), 1102 'debug' => $server_architecture, 1103 ); 1104 $fields['httpd_software'] = array( 1105 'label' => __( 'Web server' ), 1106 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ), 1107 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ), 1108 ); 1109 $fields['php_version'] = array( 1110 'label' => __( 'PHP version' ), 1111 'value' => $php_version, 1112 'debug' => $php_version_debug, 1113 ); 1114 $fields['php_sapi'] = array( 1115 'label' => __( 'PHP SAPI' ), 1116 'value' => PHP_SAPI, 1117 'debug' => PHP_SAPI, 1118 ); 1119 1120 // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values. 1121 if ( ! function_exists( 'ini_get' ) ) { 1122 $fields['ini_get'] = array( 1123 'label' => __( 'Server settings' ), 1124 'value' => sprintf( 1125 /* translators: %s: ini_get() */ 1126 __( 'Unable to determine some settings, as the %s function has been disabled.' ), 1127 'ini_get()' 1128 ), 1129 'debug' => 'ini_get() is disabled', 1130 ); 1131 } else { 1132 $fields['max_input_variables'] = array( 1133 'label' => __( 'PHP max input variables' ), 1134 'value' => ini_get( 'max_input_vars' ), 1135 ); 1136 $fields['time_limit'] = array( 1137 'label' => __( 'PHP time limit' ), 1138 'value' => ini_get( 'max_execution_time' ), 1139 ); 1140 1141 if ( WP_Site_Health::get_instance()->php_memory_limit !== ini_get( 'memory_limit' ) ) { 1142 $fields['memory_limit'] = array( 1143 'label' => __( 'PHP memory limit' ), 1144 'value' => WP_Site_Health::get_instance()->php_memory_limit, 1145 ); 1146 $fields['admin_memory_limit'] = array( 1147 'label' => __( 'PHP memory limit (only for admin screens)' ), 1148 'value' => ini_get( 'memory_limit' ), 1149 ); 1150 } else { 1151 $fields['memory_limit'] = array( 1152 'label' => __( 'PHP memory limit' ), 1153 'value' => ini_get( 'memory_limit' ), 1154 ); 1155 } 1156 1157 $fields['max_input_time'] = array( 1158 'label' => __( 'Max input time' ), 1159 'value' => ini_get( 'max_input_time' ), 1160 ); 1161 $fields['upload_max_filesize'] = array( 1162 'label' => __( 'Upload max filesize' ), 1163 'value' => ini_get( 'upload_max_filesize' ), 1164 ); 1165 $fields['php_post_max_size'] = array( 1166 'label' => __( 'PHP post max size' ), 1167 'value' => ini_get( 'post_max_size' ), 1168 ); 1169 } 1170 1171 if ( function_exists( 'curl_version' ) ) { 1172 $curl = curl_version(); 1173 1174 $fields['curl_version'] = array( 1175 'label' => __( 'cURL version' ), 1176 'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ), 1177 ); 1178 } else { 1179 $fields['curl_version'] = array( 1180 'label' => __( 'cURL version' ), 1181 'value' => __( 'Not available' ), 1182 'debug' => 'not available', 1183 ); 1184 } 1185 1186 // SUHOSIN. 1187 $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ); 1188 1189 $fields['suhosin'] = array( 1190 'label' => __( 'Is SUHOSIN installed?' ), 1191 'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ), 1192 'debug' => $suhosin_loaded, 1193 ); 1194 1195 // Imagick. 1196 $imagick_loaded = extension_loaded( 'imagick' ); 1197 1198 $fields['imagick_availability'] = array( 1199 'label' => __( 'Is the Imagick library available?' ), 1200 'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ), 1201 'debug' => $imagick_loaded, 1202 ); 1203 1204 // Pretty permalinks. 1205 $pretty_permalinks_supported = got_url_rewrite(); 1206 1207 $fields['pretty_permalinks'] = array( 1208 'label' => __( 'Are pretty permalinks supported?' ), 1209 'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ), 1210 'debug' => $pretty_permalinks_supported, 1211 ); 1212 1213 // Check if a .htaccess file exists. 1214 if ( is_file( ABSPATH . '.htaccess' ) ) { 1215 // If the file exists, grab the content of it. 1216 $htaccess_content = file_get_contents( ABSPATH . '.htaccess' ); 1217 1218 // Filter away the core WordPress rules. 1219 $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) ); 1220 $filtered_htaccess_content = ! empty( $filtered_htaccess_content ); 1221 1222 if ( $filtered_htaccess_content ) { 1223 /* translators: %s: .htaccess */ 1224 $htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' ); 1225 } else { 1226 /* translators: %s: .htaccess */ 1227 $htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' ); 1228 } 1229 1230 $fields['htaccess_extra_rules'] = array( 1231 'label' => __( '.htaccess rules' ), 1232 'value' => $htaccess_rules_string, 1233 'debug' => $filtered_htaccess_content, 1234 ); 1235 } 1236 1237 // Server time. 1238 $date = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); 1239 1240 $fields['current'] = array( 1241 'label' => __( 'Current time' ), 1242 'value' => $date->format( DateTime::ATOM ), 1243 ); 1244 $fields['utc-time'] = array( 1245 'label' => __( 'Current UTC time' ), 1246 'value' => $date->format( DateTime::RFC850 ), 1247 ); 1248 $fields['server-time'] = array( 1249 'label' => __( 'Current Server time' ), 1250 'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ), 1251 ); 1252 1253 return array( 1254 'label' => __( 'Server' ), 1255 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.' ), 1256 'fields' => $fields, 1257 ); 1258 } 1259 1260 /** 1250 1261 * Gets the WordPress constants section of the debug data. 1251 1262 *
Note: See TracChangeset
for help on using the changeset viewer.