diff --git a/mailpoet/lib/Features/FeaturesController.php b/mailpoet/lib/Features/FeaturesController.php index a7203964ed..4b1d8c6b14 100644 --- a/mailpoet/lib/Features/FeaturesController.php +++ b/mailpoet/lib/Features/FeaturesController.php @@ -13,7 +13,7 @@ class FeaturesController { self::AUTOMATION => false, ]; - /** @var array */ + /** @var array|null */ private $flags; /** @var FeatureFlagsRepository */ @@ -36,7 +36,7 @@ class FeaturesController { } catch (TableNotFoundException $e) { return $this->defaults[$feature]; } - return $this->flags[$feature]; + return ($this->flags ?? [])[$feature]; } /** @return bool */ @@ -52,7 +52,11 @@ class FeaturesController { /** @return array */ public function getAllFlags() { $this->ensureFlagsLoaded(); - return $this->flags; + return $this->flags ?? []; + } + + public function resetCache(): void { + $this->flags = null; } private function ensureFlagsLoaded() { diff --git a/mailpoet/tests/integration/_bootstrap.php b/mailpoet/tests/integration/_bootstrap.php index cfbdebb29e..956c678ccc 100644 --- a/mailpoet/tests/integration/_bootstrap.php +++ b/mailpoet/tests/integration/_bootstrap.php @@ -3,6 +3,7 @@ use MailPoet\Cache\TransientCache; use MailPoet\DI\ContainerWrapper; use MailPoet\Entities\ScheduledTaskEntity; +use MailPoet\Features\FeaturesController; use MailPoet\Settings\SettingsController; use MailPoetVendor\Doctrine\DBAL\Connection; use MailPoetVendor\Doctrine\ORM\EntityManager; @@ -122,7 +123,9 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore $this->diContainer = ContainerWrapper::getInstance(WP_DEBUG); $this->connection = $this->diContainer->get(Connection::class); $this->entityManager = $this->diContainer->get(EntityManager::class); + $this->diContainer->get(FeaturesController::class)->resetCache(); $this->diContainer->get(SettingsController::class)->resetCache(); + // Cleanup scheduled tasks from previous tests $this->truncateEntity(ScheduledTaskEntity::class); $this->entityManager->clear();