diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 3ff134fe6..27d4c70e1 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -6723,7 +6723,13 @@ abstract class MetaModel if ($bMustBeFound && empty($aRow)) { - throw new CoreException("No result for the single row query: '$sSQL'"); + $sNotFoundErrorMessage = "No result for the single row query"; + IssueLog::Info($sNotFoundErrorMessage, LogChannels::CMDB_SOURCE, [ + 'class' => $sClass, + 'key' => $iKey, + 'sql_query' => $sSQL, + ]); + throw new CoreException($sNotFoundErrorMessage); } return $aRow; diff --git a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php index 5e2291984..c9104cf9f 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php +++ b/datamodels/2.x/itop-portal-base/portal/src/Controller/ObjectController.php @@ -1035,7 +1035,11 @@ class ObjectController extends BrickController // When reaching to an Attachment, we have to check security on its host object instead of the Attachment itself if ($sObjectClass === 'Attachment') { - $oAttachment = MetaModel::GetObject($sObjectClass, $sObjectId, true, true); + + $oAttachment = MetaModel::GetObject($sObjectClass, $sObjectId, false, true); + if ($oAttachment === null) { + throw new HttpException(Response::HTTP_NOT_FOUND, Dict::S('UI:ObjectDoesNotExist')); + } $sHostClass = $oAttachment->Get('item_class'); $sHostId = $oAttachment->Get('item_id'); }