From b26fdede9092ffc83eb713ecaac6737413cc232f Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:52:26 +0100 Subject: [PATCH 1/2] Catch invalid DSN before activating --- Helper/Data.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index d4f0aee..87c533f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -365,7 +365,7 @@ public function isActiveWithReason(): array $config = $this->collectModuleConfig(); $emptyConfig = empty($config); $configEnabled = isset($config['enabled']) && $config['enabled']; - $dsnNotEmpty = $this->getDSN(); + $dsn = $this->getDSN(); $productionMode = ($this->isProductionMode() || $this->isOverwriteProductionMode()); if ($emptyConfig) { @@ -374,9 +374,16 @@ public function isActiveWithReason(): array if (!$configEnabled) { $reasons[] = __('Module is not enabled in config.'); } - if (!$dsnNotEmpty && !$this->isSpotlightEnabled()) { + if (!$dsn && !$this->isSpotlightEnabled()) { $reasons[] = __('DSN is empty.'); } + if ($dsn) { + try { + \Sentry\Dsn::createFromString($dsn); + } catch (\InvalidArgumentException $e) { + $reasons[] = $e->getMessage(); + } + } if (!$productionMode) { $reasons[] = __('Not in production and development mode is false.'); } From 7085cace7edb6c36b872763ccf4e3eea2f2cc53c Mon Sep 17 00:00:00 2001 From: indykoning <15870933+indykoning@users.noreply.github.com> Date: Wed, 26 Nov 2025 16:21:08 +0100 Subject: [PATCH 2/2] Cache isActive result --- Helper/Data.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Helper/Data.php b/Helper/Data.php index 87c533f..8e72f94 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -73,6 +73,11 @@ class Data extends AbstractHelper */ protected $config = []; + /** + * @var ?bool + */ + protected $isActive = null; + /** * @var array */ @@ -351,7 +356,7 @@ public function processConfigValue(mixed $value, array $config): mixed */ public function isActive(): bool { - return $this->isActiveWithReason()['active']; + return $this->isActive ??= $this->isActiveWithReason()['active']; } /**