From d4a696cb6b49b7af84c44c13c6f0332786063abe Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 24 Oct 2019 18:05:58 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02555=20Specific=20exception=20for=20inva?= =?UTF-8?q?lid=20action=5Frules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/coreexception.class.inc.php | 14 ++++++++++++++ .../portal/src/Helper/ContextManipulatorHelper.php | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/core/coreexception.class.inc.php b/core/coreexception.class.inc.php index 3365f8575..112c61ed1 100644 --- a/core/coreexception.class.inc.php +++ b/core/coreexception.class.inc.php @@ -183,11 +183,25 @@ class CoreCannotSaveObjectException extends CoreException } } +/** + * @since 2.7.0 N°2555 + */ +class CorePortalInvalidActionRuleException extends CoreException +{ + +} + +/** + * @since 2.7.0 N°2555 + */ class CoreOqlException extends CoreException { } +/** + * @since 2.7.0 N°2555 + */ class CoreOqlMultipleResultsForbiddenException extends CoreOqlException { diff --git a/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php b/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php index 31716ab00..5e986f169 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Helper/ContextManipulatorHelper.php @@ -25,7 +25,7 @@ namespace Combodo\iTop\Portal\Helper; use BinaryExpression; use Combodo\iTop\Portal\Brick\BrickCollection; use CoreOqlMultipleResultsForbiddenException; -use CoreUnexpectedValue; +use CorePortalInvalidActionRuleException; use DBObject; use DBSearch; use DOMFormatException; @@ -279,6 +279,7 @@ class ContextManipulatorHelper * @throws \Exception * @throws \CoreException * @throws \OQLException + * @throws \CorePortalInvalidActionRuleException N°2555 if action_rule query return more than 1 result (we should only have 1 source object) */ public function PrepareObject(array $aData, DBObject &$oObject) { @@ -351,7 +352,7 @@ class ContextManipulatorHelper // N°2555 : disallow searches without any condition $sErrMsg = "Portal query was stopped: action_rule '$sId' searches for '$sSearchClass' without any condition is forbidden"; IssueLog::Error($sErrMsg); - throw new CoreUnexpectedValue($sErrMsg); + throw new CorePortalInvalidActionRuleException($sErrMsg); } // Checking for silos @@ -372,7 +373,7 @@ class ContextManipulatorHelper // N°2555 : disallow searches returning more than 1 result $sErrMsg = "Portal query was stopped: action_rule '$sId' gives more than 1 '$sSearchClass' result"; IssueLog::Error($sErrMsg); - throw new CoreUnexpectedValue($sErrMsg); + throw new CorePortalInvalidActionRuleException($sErrMsg); } if ($oSourceObject === null) {