mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
fixes
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\MassAction\Service;
|
||||
use Espo\Core\MassAction\ServiceResult;
|
||||
@@ -139,6 +140,10 @@ class MassAction
|
||||
|
||||
$result = $serviceResult->getResult();
|
||||
|
||||
if (!$result) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
$data = (object) [];
|
||||
|
||||
if ($result->hasCount()) {
|
||||
|
||||
@@ -78,7 +78,9 @@ class DefaultOwnershipChecker implements OwnershipOwnChecker, OwnershipTeamCheck
|
||||
|
||||
public function checkTeam(User $user, Entity $entity): bool
|
||||
{
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$userTeamIdList = $user->getLinkMultipleIdList(self::FIELD_TEAMS);
|
||||
|
||||
|
||||
@@ -103,7 +103,9 @@ class EspoManager implements Manager
|
||||
|
||||
public function inactivate(AuthToken $authToken): void
|
||||
{
|
||||
assert($authToken instanceof AuthTokenEntity);
|
||||
if (!$authToken instanceof AuthTokenEntity) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
$this->validateNotChanged($authToken);
|
||||
|
||||
@@ -114,7 +116,9 @@ class EspoManager implements Manager
|
||||
|
||||
public function renew(AuthToken $authToken): void
|
||||
{
|
||||
assert($authToken instanceof AuthTokenEntity);
|
||||
if (!$authToken instanceof AuthTokenEntity) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
$this->validateNotChanged($authToken);
|
||||
|
||||
|
||||
@@ -115,7 +115,11 @@ class FindRelatedManyType extends BaseFunction implements
|
||||
$order = $order ?? 'asc';
|
||||
}
|
||||
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
$this->throwError("Only core entities are supported.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$relationType = $entity->getRelationParam($link, 'type');
|
||||
|
||||
|
||||
@@ -90,7 +90,11 @@ class FindRelatedOneType extends BaseFunction implements
|
||||
|
||||
$metadata = $this->metadata;
|
||||
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
$this->throwError("Only core entities are supported.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$relationType = $entity->getRelationParam($link, 'type');
|
||||
|
||||
|
||||
@@ -444,7 +444,9 @@ class Importer
|
||||
return;
|
||||
}
|
||||
|
||||
assert($parent instanceof CoreEntity);
|
||||
if (!$parent instanceof CoreEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
$parentTeamIdList = $parent->getLinkMultipleIdList('teams');
|
||||
|
||||
|
||||
@@ -66,8 +66,6 @@ class Process implements Job
|
||||
{
|
||||
$id = $data->getTargetId();
|
||||
|
||||
assert($id !== null);
|
||||
|
||||
if ($id === null) {
|
||||
throw new Error("ID not passed to the mass action job.");
|
||||
}
|
||||
|
||||
@@ -48,17 +48,13 @@ class ServiceResult
|
||||
return $this->result !== null;
|
||||
}
|
||||
|
||||
public function getId(): string
|
||||
public function getId(): ?string
|
||||
{
|
||||
assert($this->id !== null);
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getResult(): Result
|
||||
public function getResult(): ?Result
|
||||
{
|
||||
assert($this->result !== null);
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,9 @@ class DefaultAssignmentNotificator implements AssignmentNotificator
|
||||
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($entity->hasLinkMultipleField('assignedUsers')) {
|
||||
$userIdList = $entity->getLinkMultipleIdList('assignedUsers');
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace Espo\Core\Portal\Loaders;
|
||||
|
||||
use Espo\Core\Portal\AclManager as PortalAclManager;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use Espo\Core\{
|
||||
Container\Loader,
|
||||
AclManager,
|
||||
@@ -48,7 +50,9 @@ class Acl implements Loader
|
||||
|
||||
public function __construct(AclManager $aclManager, User $user)
|
||||
{
|
||||
assert($aclManager instanceof PortalAclManager);
|
||||
if (!$aclManager instanceof PortalAclManager) {
|
||||
throw new InvalidArgumentException();
|
||||
}
|
||||
|
||||
$this->aclManager = $aclManager;
|
||||
$this->user = $user;
|
||||
|
||||
@@ -1026,7 +1026,9 @@ class Service implements Crud,
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
throw new Error("Only core entities are supported");
|
||||
}
|
||||
|
||||
if ($this->noEditAccessRequiredForLink) {
|
||||
if (!$this->acl->check($entity, AclTable::ACTION_READ)) {
|
||||
@@ -1098,7 +1100,9 @@ class Service implements Crud,
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
throw new Error("Only core entities are supported");
|
||||
}
|
||||
|
||||
if ($this->noEditAccessRequiredForLink) {
|
||||
if (!$this->acl->check($entity, AclTable::ACTION_READ)) {
|
||||
@@ -1160,14 +1164,13 @@ class Service implements Crud,
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
/** @var User|null $user */
|
||||
$user = $this->entityManager->getEntity('User', $foreignId);
|
||||
|
||||
if (!$user) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
assert($user instanceof User);
|
||||
|
||||
if (!$this->acl->check($entity, AclTable::ACTION_EDIT)) {
|
||||
throw new ForbiddenSilent("No 'edit' access.");
|
||||
}
|
||||
@@ -1215,14 +1218,13 @@ class Service implements Crud,
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
/** @var User|null $user */
|
||||
$user = $this->entityManager->getEntity('User', $foreignId);
|
||||
|
||||
if (!$user) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
assert($user instanceof User);
|
||||
|
||||
if (!$this->acl->check($entity, AclTable::ACTION_EDIT)) {
|
||||
throw new ForbiddenSilent("No 'edit' access.");
|
||||
}
|
||||
@@ -1278,7 +1280,9 @@ class Service implements Crud,
|
||||
return $this->$methodName($id, $searchParams);
|
||||
}
|
||||
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
throw new Error("Only core entities are supported");
|
||||
}
|
||||
|
||||
$foreignEntityType = $entity->getRelationParam($link, 'entity');
|
||||
|
||||
@@ -1623,7 +1627,9 @@ class Service implements Crud,
|
||||
}
|
||||
}
|
||||
else if ($type === 'linkMultiple') {
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
throw new Error("Only core entities are supported");
|
||||
}
|
||||
|
||||
$foreignLink = $entity->getRelationParam($field, 'foreign');
|
||||
$foreignEntityType = $entity->getRelationParam($field, 'entity');
|
||||
|
||||
@@ -36,6 +36,8 @@ use Espo\Core\Field\Link;
|
||||
use Espo\Core\MassAction\Data;
|
||||
use Espo\Core\MassAction\Params;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class MassAction extends Entity
|
||||
@@ -54,12 +56,13 @@ class MassAction extends Entity
|
||||
{
|
||||
$raw = $this->get('params');
|
||||
|
||||
assert(is_string($raw));
|
||||
if (!is_string($raw)) {
|
||||
throw new Error("No 'params'.");
|
||||
}
|
||||
|
||||
/** @var Params $params */
|
||||
$params = unserialize($raw);
|
||||
|
||||
assert($params instanceof Params);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
@@ -67,7 +70,9 @@ class MassAction extends Entity
|
||||
{
|
||||
$raw = $this->get('data');
|
||||
|
||||
assert($raw instanceof stdClass);
|
||||
if (!$raw instanceof stdClass) {
|
||||
throw new Error("No 'data'.");
|
||||
}
|
||||
|
||||
return Data::fromRaw($raw);
|
||||
}
|
||||
@@ -76,7 +81,9 @@ class MassAction extends Entity
|
||||
{
|
||||
$value = $this->get('entityType');
|
||||
|
||||
assert(is_string($value));
|
||||
if (!is_string($value)) {
|
||||
throw new Error("No 'entityType'.");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -85,7 +92,9 @@ class MassAction extends Entity
|
||||
{
|
||||
$value = $this->get('action');
|
||||
|
||||
assert(is_string($value));
|
||||
if (!is_string($value)) {
|
||||
throw new Error("No 'action'.");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -94,7 +103,9 @@ class MassAction extends Entity
|
||||
{
|
||||
$value = $this->get('status');
|
||||
|
||||
assert(is_string($value));
|
||||
if (!is_string($value)) {
|
||||
throw new Error("No 'status'.");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -108,7 +119,9 @@ class MassAction extends Entity
|
||||
{
|
||||
$value = $this->getValueObject('createdAt');
|
||||
|
||||
assert($value instanceof DateTime);
|
||||
if (!$value instanceof DateTime) {
|
||||
throw new Error("No 'createdAt'.");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
@@ -117,7 +130,9 @@ class MassAction extends Entity
|
||||
{
|
||||
$value = $this->getValueObject('createdBy');
|
||||
|
||||
assert($value instanceof Link);
|
||||
if (!$value instanceof Link) {
|
||||
throw new Error("No 'createdBy'.");
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,9 @@ class RDBRepository implements Repository
|
||||
{
|
||||
$mapper = $this->getMapper();
|
||||
|
||||
assert($mapper instanceof BaseMapper);
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'restoreDeleted'.");
|
||||
}
|
||||
|
||||
$mapper->restoreDeleted($this->entityType, $id);
|
||||
}
|
||||
@@ -245,7 +247,9 @@ class RDBRepository implements Repository
|
||||
{
|
||||
$mapper = $this->getMapper();
|
||||
|
||||
assert($mapper instanceof BaseMapper);
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'deleteFromDb'.");
|
||||
}
|
||||
|
||||
$mapper->deleteFromDb($this->entityType, $id, $onlyDeleted);
|
||||
}
|
||||
@@ -287,7 +291,9 @@ class RDBRepository implements Repository
|
||||
{
|
||||
$mapper = $this->getMapper();
|
||||
|
||||
assert($mapper instanceof BaseMapper);
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'findBySql'.");
|
||||
}
|
||||
|
||||
return $mapper->selectBySql($this->entityType, $sql);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,9 @@ class RDBSelectBuilder
|
||||
|
||||
$mapper = $this->getMapper();
|
||||
|
||||
assert($mapper instanceof BaseMapper);
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'max'.");
|
||||
}
|
||||
|
||||
return $mapper->max($query, $attribute);
|
||||
}
|
||||
@@ -169,7 +171,9 @@ class RDBSelectBuilder
|
||||
|
||||
$mapper = $this->getMapper();
|
||||
|
||||
assert($mapper instanceof BaseMapper);
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'min'.");
|
||||
}
|
||||
|
||||
return $mapper->min($query, $attribute);
|
||||
}
|
||||
@@ -185,7 +189,9 @@ class RDBSelectBuilder
|
||||
|
||||
$mapper = $this->getMapper();
|
||||
|
||||
assert($mapper instanceof BaseMapper);
|
||||
if (!$mapper instanceof BaseMapper) {
|
||||
throw new RuntimeException("Not supported 'sum'.");
|
||||
}
|
||||
|
||||
return $mapper->sum($query, $attribute);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,9 @@ class AssignmentProcessor
|
||||
return;
|
||||
}
|
||||
|
||||
assert($entity instanceof Entity);
|
||||
if (!$entity instanceof Entity) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->loadParentNameFields($entity);
|
||||
|
||||
|
||||
@@ -448,7 +448,9 @@ class Import
|
||||
$entity = $this->entityManager->getEntity($this->entityType);
|
||||
}
|
||||
|
||||
assert($entity instanceof Entity);
|
||||
if (!$entity instanceof Entity) {
|
||||
throw new Error("Import supports only `Espo\Core\ORM\Entity`.");
|
||||
}
|
||||
|
||||
$isNew = $entity->isNew();
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ class HookProcessor
|
||||
{
|
||||
$entityType = $entity->getEntityType();
|
||||
|
||||
assert($entity instanceof CoreEntity);
|
||||
if (!$entity instanceof CoreEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* No need to process assignment notifications for entity types that have Stream enabled.
|
||||
|
||||
Reference in New Issue
Block a user