Skip to content

Commit 582d9d0

Browse files
Replace phpinfo with server info block
1 parent 141f0d8 commit 582d9d0

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

src/class-tiny-diagnostics.php

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,46 @@ public function collect_info() {
6464
$info = array(
6565
'timestamp' => current_time( 'Y-m-d H:i:s' ),
6666
'site_info' => self::get_site_info(),
67+
'server_info' => self::get_server_info(),
6768
'active_plugins' => self::get_active_plugins(),
6869
'tiny_info' => $this->get_tiny_info(),
6970
'image_sizes' => $this->settings->get_active_tinify_sizes(),
7071
);
7172

7273
return $info;
7374
}
75+
76+
/**
77+
* Gets server information.
78+
* We have considered phpinfo but this would be a security concern
79+
* as it contains a lot of information we probably do not need.
80+
* Whenever support needs more server information, we can manually
81+
* add it here.
82+
*
83+
* @since 3.7.0
84+
*
85+
* @return array Server information.
86+
*/
87+
private static function get_server_info() {
88+
global $wpdb;
89+
90+
return array(
91+
'php_version' => phpversion(),
92+
'server_software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ?
93+
sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) :
94+
'Unknown',
95+
'mysql_version' => $wpdb->db_version(),
96+
'max_execution_time' => ini_get( 'max_execution_time' ),
97+
'memory_limit' => ini_get( 'memory_limit' ),
98+
'post_max_size' => ini_get( 'post_max_size' ),
99+
'upload_max_filesize' => ini_get( 'upload_max_filesize' ),
100+
'max_input_vars' => ini_get( 'max_input_vars' ),
101+
'curl_version' => function_exists( 'curl_version' ) ?
102+
curl_version()['version'] :
103+
'Not available',
104+
'disabled_functions' => ini_get( 'disable_functions' ),
105+
);
106+
}
74107

75108
/**
76109
* Gets site information.
@@ -184,15 +217,6 @@ public function create_diagnostic_zip() {
184217
$info = self::collect_info();
185218
$zip->addFromString( 'tiny-diagnostics.json', wp_json_encode( $info, JSON_PRETTY_PRINT ) );
186219

187-
// Add phpinfo HTML.
188-
ob_start();
189-
phpinfo( INFO_GENERAL );
190-
phpinfo( INFO_CONFIGURATION );
191-
phpinfo( INFO_MODULES );
192-
$phpinfo_html = ob_get_clean();
193-
$zip->addFromString( 'phpinfo.html', $phpinfo_html );
194-
195-
// Add log files.
196220
$logger = Tiny_Logger::get_instance();
197221
$log_files = $logger->get_log_files();
198222

test/unit/Tiny_Diagnostics_Test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function test_collect_info_returns_info()
2929
assertArrayHasKey('timestamp', $info);
3030
assertArrayHasKey('site_info', $info);
3131
assertArrayHasKey('active_plugins', $info);
32+
assertArrayHasKey('server_info', $info);
3233
assertArrayHasKey('tiny_info', $info);
3334
assertArrayHasKey('image_sizes', $info);
3435
}

0 commit comments

Comments
 (0)