diff --git a/lib/AdminPages/Pages/Forms.php b/lib/AdminPages/Pages/Forms.php index d1a9155645..19a9966810 100644 --- a/lib/AdminPages/Pages/Forms.php +++ b/lib/AdminPages/Pages/Forms.php @@ -64,9 +64,8 @@ class Forms { $data['site_url'] = $this->wp->siteUrl(); $data['premium_plugin_active'] = License::getLicense(); $data['current_wp_user_firstname'] = $this->wp->wpGetCurrentUser()->user_firstname; - $installedAtDateTime = new \DateTime($this->settings->get('installed_at')); - $data['installed_days_ago'] = (int)$installedAtDateTime->diff(new \DateTime())->format('%a'); - + $installedAtDiff = (new \DateTime($this->settings->get('installed_at')))->diff(new \DateTime()); + $data['installed_days_ago'] = $installedAtDiff instanceof \DateInterval ? (int)$installedAtDiff->format('%a') : null; $data['display_nps_survey'] = true; $this->userFlags->set('display_new_form_editor_nps_survey', false); } diff --git a/lib/AdminPages/Pages/Newsletters.php b/lib/AdminPages/Pages/Newsletters.php index d7364ce4b2..76fd0c0c86 100644 --- a/lib/AdminPages/Pages/Newsletters.php +++ b/lib/AdminPages/Pages/Newsletters.php @@ -133,8 +133,9 @@ class Newsletters { $data['roles'] = $wp_roles->get_names(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps $data['roles']['mailpoet_all'] = $this->wp->__('In any WordPress role', 'mailpoet'); - $installedAtDateTime = new \DateTime($data['settings']['installed_at']); - $data['installed_days_ago'] = (int)$installedAtDateTime->diff(new \DateTime())->format('%a'); + $installedAtDiff = (new \DateTime($this->settings->get('installed_at')))->diff(new \DateTime()); + $data['installed_days_ago'] = $installedAtDiff instanceof \DateInterval ? (int)$installedAtDiff->format('%a') : null; + $data['subscribers_limit'] = $this->subscribersFeature->getSubscribersLimit(); $data['subscribers_limit_reached'] = $this->subscribersFeature->check(); $data['has_valid_api_key'] = $this->subscribersFeature->hasValidApiKey(); diff --git a/lib/Cron/Workers/ExportFilesCleanup.php b/lib/Cron/Workers/ExportFilesCleanup.php index e64d187e28..2c7213d0d4 100644 --- a/lib/Cron/Workers/ExportFilesCleanup.php +++ b/lib/Cron/Workers/ExportFilesCleanup.php @@ -19,7 +19,7 @@ class ExportFilesCleanup extends SimpleWorker { $name = $file->getPathname(); $created = $file->getMTime(); $now = new Carbon(); - if (Carbon::createFromTimestamp($created)->lessThan($now->subDays(self::DELETE_FILES_AFTER_X_DAYS))) { + if (Carbon::createFromTimestamp((int)$created)->lessThan($now->subDays(self::DELETE_FILES_AFTER_X_DAYS))) { unlink($name); }; } diff --git a/lib/Doctrine/MetadataCache.php b/lib/Doctrine/MetadataCache.php index caa0bbab22..835a6ea22c 100644 --- a/lib/Doctrine/MetadataCache.php +++ b/lib/Doctrine/MetadataCache.php @@ -42,6 +42,9 @@ class MetadataCache extends CacheProvider { if ($fileExists && $this->isDevMode) { $classMetadata = unserialize((string)file_get_contents($filename)); assert($classMetadata instanceof DoctrineClassMetadata || $classMetadata instanceof ValidatorClassMetadata); + if (!class_exists($classMetadata->name)) { + return false; + } try { $reflection = new ReflectionClass($classMetadata->name); } catch (ReflectionException $e) { diff --git a/lib/DynamicSegments/RequirementsChecker.php b/lib/DynamicSegments/RequirementsChecker.php index 2458c23db8..e30907e50a 100644 --- a/lib/DynamicSegments/RequirementsChecker.php +++ b/lib/DynamicSegments/RequirementsChecker.php @@ -34,7 +34,7 @@ class RequirementsChecker { $className = get_class($filter); $ref = new \ReflectionClass($className); - $constants = $ref->getConstants(); + $constants = $ref->getConstants() ?? []; if (!array_key_exists('SEGMENT_TYPE', $constants)) { return true; } diff --git a/lib/Entities/SettingEntity.php b/lib/Entities/SettingEntity.php index de373c3bcd..68a1cc08c0 100644 --- a/lib/Entities/SettingEntity.php +++ b/lib/Entities/SettingEntity.php @@ -43,7 +43,7 @@ class SettingEntity { /** @return mixed */ public function getValue() { - return is_serialized($this->value) ? unserialize($this->value) : $this->value; + return $this->value !== null && is_serialized($this->value) ? unserialize($this->value) : $this->value; } /** @param mixed $value */ diff --git a/lib/Features/FeatureFlagsController.php b/lib/Features/FeatureFlagsController.php index cb0876be18..c156f71d97 100644 --- a/lib/Features/FeatureFlagsController.php +++ b/lib/Features/FeatureFlagsController.php @@ -36,9 +36,6 @@ class FeatureFlagsController { ), $flags ); - if ($flagsMap === false) { - $flagsMap = []; - } $output = []; foreach ($this->featuresController->getDefaults() as $name => $default) { diff --git a/lib/Mailer/Methods/AmazonSES.php b/lib/Mailer/Methods/AmazonSES.php index 29003911d8..a9e1dee3c5 100644 --- a/lib/Mailer/Methods/AmazonSES.php +++ b/lib/Mailer/Methods/AmazonSES.php @@ -168,7 +168,7 @@ class AmazonSES { 'Authorization' => $this->signRequest($body), 'X-Amz-Date' => $this->date, ], - 'body' => urldecode(http_build_query($body, null, '&')), + 'body' => urldecode(http_build_query($body, '', '&')), ]; } @@ -209,7 +209,7 @@ class AmazonSES { 'x-amz-date:' . $this->date, '', 'host;x-amz-date', - hash($this->hashAlgorithm, urldecode(http_build_query($body, null, '&'))), + hash($this->hashAlgorithm, urldecode(http_build_query($body, '', '&'))), ]); } diff --git a/lib/Mailer/Methods/SendGrid.php b/lib/Mailer/Methods/SendGrid.php index 856f0bf09b..ab666f11f8 100644 --- a/lib/Mailer/Methods/SendGrid.php +++ b/lib/Mailer/Methods/SendGrid.php @@ -88,7 +88,7 @@ class SendGrid { 'headers' => [ 'Authorization' => $this->auth(), ], - 'body' => http_build_query($body, null, '&'), + 'body' => http_build_query($body, '', '&'), ]; } } diff --git a/lib/Newsletter/Editor/PostContentManager.php b/lib/Newsletter/Editor/PostContentManager.php index 54c3124c3b..47bdd7d0eb 100644 --- a/lib/Newsletter/Editor/PostContentManager.php +++ b/lib/Newsletter/Editor/PostContentManager.php @@ -60,6 +60,10 @@ class PostContentManager { $tagsNotBeingStripped = array_merge($tagsNotBeingStripped, ['
', '', '

', '

', '

']); } + if (is_array($content)) { + $content = implode(' ', $content); + } + $content = strip_tags($content, implode('', $tagsNotBeingStripped)); if ($withPostClass) { $content = str_replace('wpautop($content));