Make sure offset is always number
We want to prevent an error 'Unsupported operand types: string * int' [MAILPOET-5676]
This commit is contained in:
committed by
Rostislav Wolný
parent
8f1cdc6a0d
commit
b60da9faf6
@ -74,7 +74,7 @@ class Env {
|
||||
if ($parsedHost === false) {
|
||||
throw new \InvalidArgumentException('Invalid db host configuration.');
|
||||
}
|
||||
list($host, $port, $socket, $isIpv6) = $parsedHost;
|
||||
[$host, $port, $socket, $isIpv6] = $parsedHost;
|
||||
|
||||
global $wpdb;
|
||||
self::$dbPrefix = $wpdb->prefix . self::$pluginPrefix;
|
||||
@ -93,6 +93,7 @@ class Env {
|
||||
|
||||
public static function getDbTimezoneOffset($offset = false) {
|
||||
$offset = ($offset) ? $offset : WPFunctions::get()->getOption('gmt_offset');
|
||||
$offset = (float)($offset);
|
||||
$mins = $offset * 60;
|
||||
$sgn = ($mins < 0 ? -1 : 1);
|
||||
$mins = abs($mins);
|
||||
|
@ -86,6 +86,7 @@ class EnvTest extends \MailPoetTest {
|
||||
verify(Env::getDbTimezoneOffset('+1.5'))->equals("+01:30");
|
||||
verify(Env::getDbTimezoneOffset('+11'))->equals("+11:00");
|
||||
verify(Env::getDbTimezoneOffset('-5.5'))->equals("-05:30");
|
||||
verify(Env::getDbTimezoneOffset('xyz'))->equals("+00:00");
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
|
Reference in New Issue
Block a user