Merge remote-tracking branch 'origin/support/2.7' into support/3.0

This commit is contained in:
Pierre Goiffon
2023-09-19 09:58:40 +02:00
2 changed files with 12 additions and 2 deletions

View File

@@ -6956,7 +6956,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;

View File

@@ -1037,7 +1037,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');
}