From 6acfe62290e639a1cd895ad5078a7e842300d3be Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Thu, 28 May 2026 06:19:56 +0200 Subject: [PATCH] fix(state): correct inverted boolean conversion and empty-if status-code bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit C1: fix boolean-to-string conversion in updateEmailSettings — inverted empty-if caused every boolean true to persist as string 'false'. C3: fix empty-if branches that leave status-code/message variables at their wrong default values: - syncOrganisations: statusCode stayed 500 on success (now 200) - cancelArchiMateImport: message stayed 'failed' on success - updateEmailTemplate: message stayed 'failed' on success - updateCronjobConfig: statusCode stayed 400 on success (now 200) - forceUpdate (SettingsService): messageValue never set to success message - getVersionInfo: versionComparisonValue always null even when version available - getTransportConfig SMTP: usernameValue always 'none' even when configured - forceManualImport: reasonValue always 'auto_config_not_completed' even on force --- lib/Controller/SettingsController.php | 16 ++++------------ lib/Service/SettingsService.php | 20 +++++--------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 6ca1b52a..85e42d65 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -2167,9 +2167,7 @@ public function updateEmailTemplate(string $templateName): JSONResponse templateContent: $templateContent ); - $updateMsg = "Failed to update template {$templateName}"; - if ($success === true) { - } + $updateMsg = ($success === true) ? "Template {$templateName} updated successfully" : "Failed to update template {$templateName}"; return new JSONResponse( [ @@ -2713,9 +2711,7 @@ public function cancelArchiMateImport(): JSONResponse try { $result = $this->settingsService->cancelArchiMateImport(); - $message = 'ArchiMate import cancellation failed'; - if ($result['cancelled'] === true) { - } + $message = ($result['cancelled'] === true) ? 'ArchiMate import cancellation succeeded' : 'ArchiMate import cancellation failed'; return new JSONResponse( [ @@ -3436,9 +3432,7 @@ public function syncOrganisations(): JSONResponse // Call the settings service method. $result = $this->settingsService->syncOrganisationsToVoorzieningenOptimized($options); - $statusCode = 500; - if ($result['success'] === true) { - } + $statusCode = ($result['success'] === true) ? 200 : 500; $this->logger->info( 'SettingsController: Organisation sync completed', @@ -3581,9 +3575,7 @@ public function updateCronjobConfig(): JSONResponse $data = $this->request->getParams(); $result = $this->settingsService->updateCronjobConfig($data); - $statusCode = 400; - if ($result['success'] === true) { - } + $statusCode = ($result['success'] === true) ? 200 : 400; return new JSONResponse($result, $statusCode); } catch (\Exception $e) { diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 2b2c2f6e..4ad362eb 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -2093,9 +2093,7 @@ public function updateEmailSettings(array $emailSettings): array // Convert boolean values to strings. if (is_bool($value) === true) { - $value = 'false'; - if ($value === true) { - } + $value = ($value === true) ? 'true' : 'false'; } $this->config->setValueString($this->appName, $configKey, (string) $value); @@ -2631,9 +2629,7 @@ private function getConnectionDetails(array $emailSettings): array switch ($transportType) { case 'smtp': - $usernameValue = 'none'; - if (empty($emailSettings['smtpUsername']) === false) { - } + $usernameValue = (empty($emailSettings['smtpUsername']) === false) ? 'configured' : 'none'; return [ 'type' => 'SMTP', 'host' => $emailSettings['smtpHost'] ?? '', @@ -2971,9 +2967,7 @@ public function getVersionInfo(): array $openRegisterInstalled = $this->isOpenRegisterInstalled(); $openRegisterEnabled = $openRegisterInstalled && $this->isOpenRegisterEnabled(); - $versionComparisonValue = null; - if ($storedConfigVersion !== null) { - } + $versionComparisonValue = ($storedConfigVersion !== null) ? version_compare($currentAppVersion, $storedConfigVersion) : null; $versionInfo = [ 'appName' => 'SoftwareCatalog', @@ -3055,9 +3049,7 @@ public function forceUpdate(): array ); // Return concise response to avoid serialization issues with large nested structures. - $messageValue = 'Force update completed but configuration needs attention'; - if ($success === true) { - } + $messageValue = ($success === true) ? 'Force update completed successfully' : 'Force update completed but configuration needs attention'; return [ 'success' => $success, @@ -3207,9 +3199,7 @@ public function manualImport(bool $forceImport=false): array // If force import is requested or auto-config not completed, reset auto-configuration flag. if ($forceImport === true || $versionInfo['autoConfigCompleted'] === false) { $this->config->setValueString($this->appName, 'auto_config_completed', 'false'); - $reasonValue = 'auto_config_not_completed'; - if ($forceImport === true) { - } + $reasonValue = ($forceImport === true) ? 'force_import_requested' : 'auto_config_not_completed'; $this->logger->info( 'SettingsService: Reset auto-configuration flag',