Skip to content

Commit 2d7613a

Browse files
committed
fix: prevent duplicate log warnings for console requests in Settings model
1 parent 7903d35 commit 2d7613a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/models/Settings.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function validateLogLevel($attribute, $params, $validator)
104104
$logLevel = $this->$attribute;
105105

106106
// Reset session warning when devMode is true - allows warning to show again if devMode changes
107-
if (Craft::$app->getConfig()->getGeneral()->devMode) {
107+
if (Craft::$app->getConfig()->getGeneral()->devMode && !Craft::$app->getRequest()->getIsConsoleRequest()) {
108108
Craft::$app->getSession()->remove('im_debug_config_warning');
109109
}
110110

@@ -114,9 +114,15 @@ public function validateLogLevel($attribute, $params, $validator)
114114

115115
// Only log warning once per session for config overrides
116116
if ($this->isOverriddenByConfig('logLevel')) {
117-
if (Craft::$app->getSession()->get('im_debug_config_warning') === null) {
117+
if (!Craft::$app->getRequest()->getIsConsoleRequest()) {
118+
// Web request - use session to prevent duplicate warnings
119+
if (Craft::$app->getSession()->get('im_debug_config_warning') === null) {
120+
Craft::warning('Log level "debug" from config file changed to "info" because devMode is disabled. Please update your config/icon-manager.php file.', 'icon-manager');
121+
Craft::$app->getSession()->set('im_debug_config_warning', true);
122+
}
123+
} else {
124+
// Console request - just log without session
118125
Craft::warning('Log level "debug" from config file changed to "info" because devMode is disabled. Please update your config/icon-manager.php file.', 'icon-manager');
119-
Craft::$app->getSession()->set('im_debug_config_warning', true);
120126
}
121127
} else {
122128
// Database setting - save the correction

0 commit comments

Comments
 (0)