From 95e7d02c7cec115cac37ca8ccdc695e4491291cd Mon Sep 17 00:00:00 2001 From: nuxsmin Date: Mon, 16 Jul 2018 01:41:39 +0200 Subject: [PATCH] * [FIX] Fixed wrong behaviour when config parameter was not found --- .../web/Controllers/ConfigManagerController.php | 7 ++++--- lib/SP/Services/Config/ConfigService.php | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/modules/web/Controllers/ConfigManagerController.php b/app/modules/web/Controllers/ConfigManagerController.php index 23748c7f..f11c4c06 100644 --- a/app/modules/web/Controllers/ConfigManagerController.php +++ b/app/modules/web/Controllers/ConfigManagerController.php @@ -237,10 +237,11 @@ class ConfigManagerController extends ControllerBase $configService = $this->dic->get(ConfigService::class); $template->assign('lastUpdateMPass', $configService->getByParam('lastupdatempass', 0)); - $template->assign('tempMasterPassTime', $configService->getByParam('tempmaster_passtime', 0)); - $template->assign('tempMasterMaxTime', $configService->getByParam('tempmaster_maxtime', 0)); - $tempMasterAttempts = sprintf('%d/%d', $configService->getByParam('tempmaster_attempts', 0), TemporaryMasterPassService::MAX_ATTEMPTS); + $template->assign('tempMasterPassTime', $configService->getByParam(TemporaryMasterPassService::PARAM_TIME, 0)); + $template->assign('tempMasterMaxTime', $configService->getByParam(TemporaryMasterPassService::PARAM_MAX_TIME, 0)); + + $tempMasterAttempts = sprintf('%d/%d', $configService->getByParam(TemporaryMasterPassService::PARAM_ATTEMPTS, 0), TemporaryMasterPassService::MAX_ATTEMPTS); $template->assign('tempMasterAttempts', $tempMasterAttempts); $template->assign('tempMasterPass', $this->session->getTemporaryMasterPass()); diff --git a/lib/SP/Services/Config/ConfigService.php b/lib/SP/Services/Config/ConfigService.php index 2993eea9..65b73173 100644 --- a/lib/SP/Services/Config/ConfigService.php +++ b/lib/SP/Services/Config/ConfigService.php @@ -63,9 +63,13 @@ class ConfigService extends Service if ($result->getNumRows() === 0) { - throw new NoSuchItemException( - sprintf(__('ParĂ¡metro no encontrado (%s)'), $param) - ); + if ($default === null) { + throw new NoSuchItemException( + sprintf(__('ParĂ¡metro no encontrado (%s)'), $param) + ); + } + + return $default; } /** @var ConfigData $data */