diff --git a/application/Espo/Core/Acl.php b/application/Espo/Core/Acl.php index e0903429d0..e9ab36dcd8 100644 --- a/application/Espo/Core/Acl.php +++ b/application/Espo/Core/Acl.php @@ -24,6 +24,8 @@ namespace Espo\Core; use \Espo\Core\Exceptions\Error; +use \Espo\ORM\Entity; + class Acl { private $data = array(); @@ -132,8 +134,10 @@ class Acl return $this->checkScope($subject, $action, $isOwner, $inTeam); } else { $entity = $subject; - $entityName = $entity->getEntityName(); - return $this->checkScope($entityName, $action, $this->checkIsOwner($entity), $inTeam, $entity); + if ($entity instanceof Entity) { + $entityName = $entity->getEntityName(); + return $this->checkScope($entityName, $action, $this->checkIsOwner($entity), $inTeam, $entity); + } } } diff --git a/application/Espo/EntryPoints/Image.php b/application/Espo/EntryPoints/Image.php index c91703575c..976a768ce0 100644 --- a/application/Espo/EntryPoints/Image.php +++ b/application/Espo/EntryPoints/Image.php @@ -72,7 +72,7 @@ class Image extends \Espo\Core\EntryPoints\Base if ($attachment->get('parentId') && $attachment->get('parentType')) { $parent = $this->getEntityManager()->getEntity($attachment->get('parentType'), $attachment->get('parentId')); - if (!$this->getAcl()->check($parent)) { + if ($parent && !$this->getAcl()->check($parent)) { throw new Forbidden(); } }