diff --git a/lib/Cron/CronHelper.php b/lib/Cron/CronHelper.php index c29c0edecb..63c45ebd21 100644 --- a/lib/Cron/CronHelper.php +++ b/lib/Cron/CronHelper.php @@ -186,20 +186,23 @@ class CronHelper { throw new \Exception(__('Site URL is unreachable.', 'mailpoet')); } - $scheme = ''; + $callScheme = ''; if (isset($parsedUrl['scheme']) && ($parsedUrl['scheme'] === 'https')) { - $scheme = 'ssl://'; + $callScheme = 'ssl://'; } + // 1. if site URL does not contain a port, return the URL if (!isset($parsedUrl['port']) || empty($parsedUrl['port'])) return $siteUrl; // 2. if site URL contains valid port, try connecting to it - $fp = @fsockopen($scheme . $parsedUrl['host'], $parsedUrl['port'], $errno, $errstr, 1); + $urlHost = $parsedUrl['host'] ?? ''; + $fp = @fsockopen($callScheme . $urlHost, $parsedUrl['port'], $errno, $errstr, 1); if ($fp) return $siteUrl; // 3. if connection fails, attempt to connect the standard port derived from URL // schema - $port = (strtolower($parsedUrl['scheme']) === 'http') ? 80 : 443; - $fp = @fsockopen($scheme . $parsedUrl['host'], $port, $errno, $errstr, 1); - if ($fp) return sprintf('%s://%s', $parsedUrl['scheme'], $parsedUrl['host']); + $urlScheme = $parsedUrl['scheme'] ?? ''; + $port = (strtolower($urlScheme) === 'http') ? 80 : 443; + $fp = @fsockopen($callScheme . $urlHost, $port, $errno, $errstr, 1); + if ($fp) return sprintf('%s://%s', $urlScheme, $urlHost); // 4. throw an error if all connection attempts failed throw new \Exception(__('Site URL is unreachable.', 'mailpoet')); } diff --git a/lib/Doctrine/Types/JsonType.php b/lib/Doctrine/Types/JsonType.php index ea8932ad23..e4d46e0ad7 100644 --- a/lib/Doctrine/Types/JsonType.php +++ b/lib/Doctrine/Types/JsonType.php @@ -36,7 +36,7 @@ class JsonType extends Type { $value = stream_get_contents($value); } - $value = mb_convert_encoding($value, 'UTF-8', 'UTF-8'); // sanitize invalid utf8 + $value = mb_convert_encoding((string)$value, 'UTF-8', 'UTF-8'); // sanitize invalid utf8 $decoded = json_decode($value, true); $this->handleErrors(); return $decoded; diff --git a/lib/Form/Widget.php b/lib/Form/Widget.php index 7f47071da1..c0136fe911 100644 --- a/lib/Form/Widget.php +++ b/lib/Form/Widget.php @@ -168,6 +168,7 @@ class Widget extends \WP_Widget { } setTimestamp(); $this->newRecord = $this->isNew(); @@ -387,7 +391,7 @@ class Model extends \MailPoetVendor\Sudzy\ValidModel { public function __set($name, $value) { $name = Helpers::camelCaseToUnderscore($name); - return parent::__set($name, $value); + parent::__set($name, $value); } public function __isset($name) {