Limits utf8 encoding to php_uname function only (Windows may use an

encoding other than ISO-8859-1 in non-English locales)
This commit is contained in:
Vlad
2017-06-06 18:16:04 -04:00
parent d0bdb1a47b
commit a37ff8d398
2 changed files with 3 additions and 5 deletions

View File

@ -20,7 +20,7 @@ class Beacon {
CronDaemon::ACTION_PING CronDaemon::ACTION_PING
); );
$cron_ping_url = str_replace(home_url(), CronHelper::getSiteUrl(), $cron_ping_url); $cron_ping_url = str_replace(home_url(), CronHelper::getSiteUrl(), $cron_ping_url);
$beacon_data = array( return array(
'name' => $current_user->display_name, 'name' => $current_user->display_name,
'email' => $current_user->user_email, 'email' => $current_user->user_email,
'PHP version' => PHP_VERSION, 'PHP version' => PHP_VERSION,
@ -29,7 +29,7 @@ class Beacon {
'WordPress version' => get_bloginfo('version'), 'WordPress version' => get_bloginfo('version'),
'Database version' => $db_version, 'Database version' => $db_version,
'Web server' => (!empty($_SERVER["SERVER_SOFTWARE"])) ? $_SERVER["SERVER_SOFTWARE"] : 'N/A', 'Web server' => (!empty($_SERVER["SERVER_SOFTWARE"])) ? $_SERVER["SERVER_SOFTWARE"] : 'N/A',
'Server OS' => (function_exists('php_uname')) ? php_uname() : 'N/A', 'Server OS' => (function_exists('php_uname')) ? utf8_encode(php_uname()) : 'N/A',
'WP_MEMORY_LIMIT' => WP_MEMORY_LIMIT, 'WP_MEMORY_LIMIT' => WP_MEMORY_LIMIT,
'WP_MAX_MEMORY_LIMIT' => WP_MAX_MEMORY_LIMIT, 'WP_MAX_MEMORY_LIMIT' => WP_MAX_MEMORY_LIMIT,
'WP_DEBUG' => WP_DEBUG, 'WP_DEBUG' => WP_DEBUG,
@ -54,7 +54,5 @@ class Beacon {
'Bounce Email Address' => Setting::getValue('bounce.address'), 'Bounce Email Address' => Setting::getValue('bounce.address'),
'Total number of subscribers' => Subscriber::getTotalSubscribers() 'Total number of subscribers' => Subscriber::getTotalSubscribers()
); );
return array_map('utf8_encode', $beacon_data);
} }
} }

View File

@ -116,7 +116,7 @@ class BeaconTest extends MailPoetTest {
} }
function testItReturnsServerOSInformation() { function testItReturnsServerOSInformation() {
expect($this->beacon_data['Server OS'])->equals(php_uname()); expect($this->beacon_data['Server OS'])->equals(utf8_encode(php_uname()));
} }
function testItReturnsCronPingResponse() { function testItReturnsCronPingResponse() {