diff --git a/application/Espo/EntryPoints/Attachment.php b/application/Espo/EntryPoints/Attachment.php index ab9f296b8d..5eb4ef88fe 100644 --- a/application/Espo/EntryPoints/Attachment.php +++ b/application/Espo/EntryPoints/Attachment.php @@ -55,7 +55,7 @@ class Attachment implements EntryPoint $id = $request->getQueryParam('id'); if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $attachment = $this->entityManager @@ -63,15 +63,15 @@ class Attachment implements EntryPoint ->getById($id); if (!$attachment) { - throw new NotFound(); + throw new NotFound("Attachment not found."); } if (!$this->acl->checkEntity($attachment)) { - throw new Forbidden(); + throw new Forbidden("No access to attachment."); } if (!$this->fileStorageManager->exists($attachment)) { - throw new NotFound(); + throw new NotFound("File not found."); } $fileType = $attachment->getType(); diff --git a/application/Espo/EntryPoints/ChangePassword.php b/application/Espo/EntryPoints/ChangePassword.php index b1ca89f145..d8ce7bf8c1 100644 --- a/application/Espo/EntryPoints/ChangePassword.php +++ b/application/Espo/EntryPoints/ChangePassword.php @@ -54,7 +54,7 @@ class ChangePassword implements EntryPoint $requestId = $request->getQueryParam('id'); if (!$requestId) { - throw new BadRequest(); + throw new BadRequest("No request ID."); } $passwordChangeRequest = $this->entityManager diff --git a/application/Espo/EntryPoints/ConfirmOptIn.php b/application/Espo/EntryPoints/ConfirmOptIn.php index edd60caea6..6799d96e34 100644 --- a/application/Espo/EntryPoints/ConfirmOptIn.php +++ b/application/Espo/EntryPoints/ConfirmOptIn.php @@ -65,7 +65,7 @@ class ConfirmOptIn implements EntryPoint $id = $request->getQueryParam('id'); if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $result = $this->service->confirmOptIn($id); diff --git a/application/Espo/EntryPoints/Download.php b/application/Espo/EntryPoints/Download.php index 6fa6411c75..0a1fc20f58 100644 --- a/application/Espo/EntryPoints/Download.php +++ b/application/Espo/EntryPoints/Download.php @@ -55,22 +55,22 @@ class Download implements EntryPoint $id = $request->getQueryParam('id'); if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } /** @var ?AttachmentEntity $attachment */ $attachment = $this->entityManager->getEntityById(AttachmentEntity::ENTITY_TYPE, $id); if (!$attachment) { - throw new NotFoundSilent(); + throw new NotFoundSilent("Attachment not found."); } if (!$this->acl->checkEntity($attachment)) { - throw new Forbidden(); + throw new Forbidden("No access to attachment."); } if ($attachment->isBeingUploaded()) { - throw new Forbidden(); + throw new Forbidden("Attachment is being uploaded."); } $stream = $this->fileStorageManager->getStream($attachment); diff --git a/application/Espo/EntryPoints/Image.php b/application/Espo/EntryPoints/Image.php index 9c532f5621..0679db2804 100644 --- a/application/Espo/EntryPoints/Image.php +++ b/application/Espo/EntryPoints/Image.php @@ -72,7 +72,7 @@ class Image implements EntryPoint $size = $request->getQueryParam('size') ?? null; if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $this->show($response, $id, $size); @@ -90,7 +90,7 @@ class Image implements EntryPoint $attachment = $this->entityManager->getEntityById(Attachment::ENTITY_TYPE, $id); if (!$attachment) { - throw new NotFoundSilent(); + throw new NotFoundSilent("Attachment not found."); } if (!$disableAccessCheck && !$this->acl->checkEntity($attachment)) { @@ -105,13 +105,13 @@ class Image implements EntryPoint if ($this->allowedRelatedTypeList) { if (!in_array($attachment->getRelatedType(), $this->allowedRelatedTypeList)) { - throw new NotFoundSilent(); + throw new NotFoundSilent("Not allowed related type."); } } if ($this->allowedFieldList) { if (!in_array($attachment->getTargetField(), $this->allowedFieldList)) { - throw new NotFoundSilent(); + throw new NotFoundSilent("Not allowed field."); } } @@ -175,7 +175,7 @@ class Image implements EntryPoint $filePath = $this->getAttachmentRepository()->getFilePath($attachment); if (!$this->fileManager->isFile($filePath)) { - throw new NotFound(); + throw new NotFound("File not found."); } $fileType = $attachment->getType() ?? ''; diff --git a/application/Espo/EntryPoints/LogoImage.php b/application/Espo/EntryPoints/LogoImage.php index 815ae32e99..da6aabeda8 100644 --- a/application/Espo/EntryPoints/LogoImage.php +++ b/application/Espo/EntryPoints/LogoImage.php @@ -51,7 +51,7 @@ class LogoImage extends Image } if (!$id) { - throw new NotFound(); + throw new NotFound("No id."); } $this->show($response, $id, $size); diff --git a/application/Espo/EntryPoints/Pdf.php b/application/Espo/EntryPoints/Pdf.php index a469f0a7f1..551017c4a3 100644 --- a/application/Espo/EntryPoints/Pdf.php +++ b/application/Espo/EntryPoints/Pdf.php @@ -57,15 +57,19 @@ class Pdf implements EntryPoint $templateId = $request->getQueryParam('templateId'); if (!$entityId || !$entityType || !$templateId) { - throw new BadRequest(); + throw new BadRequest("No entityId or entityType or templateId."); } $entity = $this->entityManager->getEntityById($entityType, $entityId); /** @var ?Template $template */ $template = $this->entityManager->getEntityById(Template::ENTITY_TYPE, $templateId); - if (!$entity || !$template) { - throw new NotFound(); + if (!$entity) { + throw new NotFound("Record not found."); + } + + if (!$template) { + throw new NotFound("Template not found."); } $contents = $this->service->generate($entityType, $entityId, $templateId); diff --git a/application/Espo/Modules/Crm/Controllers/Call.php b/application/Espo/Modules/Crm/Controllers/Call.php index 8363e87c02..bc3c02c247 100644 --- a/application/Espo/Modules/Crm/Controllers/Call.php +++ b/application/Espo/Modules/Crm/Controllers/Call.php @@ -82,7 +82,7 @@ class Call extends Record $id = $request->getParsedBody()->id ?? null; if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $invitees = $this->fetchInvitees($request); @@ -108,21 +108,21 @@ class Call extends Record } if (!is_array($targets)) { - throw new BadRequest(); + throw new BadRequest("No targets."); } $invitees = []; foreach ($targets as $target) { if (!$target instanceof stdClass) { - throw new BadRequest(); + throw new BadRequest("Bad target."); } $targetEntityType = $target->entityType ?? null; $targetId = $target->id ?? null; if (!is_string($targetEntityType) || !is_string($targetId)) { - throw new BadRequest(); + throw new BadRequest("No entityType or id."); } $invitees[] = new Invitee($targetEntityType, $targetId); @@ -179,7 +179,7 @@ class Call extends Record $data = $request->getParsedBody(); if (empty($data->id) || empty($data->status)) { - throw new BadRequest(); + throw new BadRequest("No id or status."); } $this->injectableFactory @@ -199,7 +199,7 @@ class Call extends Record $id = $request->getRouteParam('id'); if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $collection = $this->injectableFactory diff --git a/application/Espo/Modules/Crm/Controllers/Meeting.php b/application/Espo/Modules/Crm/Controllers/Meeting.php index bb91d8642e..03ab7d1aec 100644 --- a/application/Espo/Modules/Crm/Controllers/Meeting.php +++ b/application/Espo/Modules/Crm/Controllers/Meeting.php @@ -61,7 +61,7 @@ class Meeting extends Record $id = $request->getParsedBody()->id ?? null; if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $invitees = $this->fetchInvitees($request); @@ -85,7 +85,7 @@ class Meeting extends Record $id = $request->getParsedBody()->id ?? null; if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $invitees = $this->fetchInvitees($request); @@ -111,21 +111,21 @@ class Meeting extends Record } if (!is_array($targets)) { - throw new BadRequest(); + throw new BadRequest("No targets."); } $invitees = []; foreach ($targets as $target) { if (!$target instanceof stdClass) { - throw new BadRequest(); + throw new BadRequest("Bad target."); } $targetEntityType = $target->entityType ?? null; $targetId = $target->id ?? null; if (!is_string($targetEntityType) || !is_string($targetId)) { - throw new BadRequest(); + throw new BadRequest("No entityType or id."); } $invitees[] = new Invitee($targetEntityType, $targetId); @@ -182,7 +182,7 @@ class Meeting extends Record $data = $request->getParsedBody(); if (empty($data->id) || empty($data->status)) { - throw new BadRequest(); + throw new BadRequest("No id or status."); } $this->injectableFactory @@ -202,7 +202,7 @@ class Meeting extends Record $id = $request->getRouteParam('id'); if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $collection = $this->injectableFactory diff --git a/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php b/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php index 36ff432e43..a28afaf378 100644 --- a/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php +++ b/application/Espo/Modules/Crm/EntryPoints/CampaignTrackOpened.php @@ -59,16 +59,16 @@ class CampaignTrackOpened implements EntryPoint $id = $request->getQueryParam('id'); if (!$id || !is_string($id)) { - throw new BadRequest(); + throw new BadRequest("No id."); } $queueItemId = $id; /** @var ?EmailQueueItem $queueItem */ - $queueItem = $this->entityManager->getEntity(EmailQueueItem::ENTITY_TYPE, $queueItemId); + $queueItem = $this->entityManager->getEntityById(EmailQueueItem::ENTITY_TYPE, $queueItemId); if (!$queueItem) { - throw new NotFound(); + throw new NotFound("Item not found."); } $targetType = $queueItem->getTargetType(); diff --git a/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php b/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php index 0a8f205c90..c13e520da1 100644 --- a/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php +++ b/application/Espo/Modules/Crm/EntryPoints/CampaignUrl.php @@ -73,14 +73,14 @@ class CampaignUrl implements EntryPoint $uid = $request->getQueryParam('uid') ?? null; if (!$trackingUrlId || !is_string($trackingUrlId)) { - throw new BadRequest(); + throw new BadRequest("No tracking URL ID."); } /** @var ?CampaignTrackingUrl $trackingUrl */ $trackingUrl = $this->entityManager->getEntityById(CampaignTrackingUrl::ENTITY_TYPE, $trackingUrlId); if (!$trackingUrl) { - throw new NotFoundSilent("Tracking URL '{$trackingUrlId}' not found."); + throw new NotFoundSilent("Tracking URL '$trackingUrlId' not found."); } if ($emailAddress && $hash) { @@ -91,14 +91,14 @@ class CampaignUrl implements EntryPoint } else { if (!$queueItemId || !is_string($queueItemId)) { - throw new BadRequest(); + throw new BadRequest("No item ID."); } /** @var ?EmailQueueItem $queueItem */ $queueItem = $this->entityManager->getEntityById(EmailQueueItem::ENTITY_TYPE, $queueItemId); if (!$queueItem) { - throw new NotFoundSilent(); + throw new NotFoundSilent("Item not found."); } $this->processWithQueueItem($trackingUrl, $queueItem); diff --git a/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php b/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php index ca3f62520f..08c41dc7b1 100644 --- a/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php +++ b/application/Espo/Modules/Crm/EntryPoints/EventConfirmation.php @@ -76,11 +76,11 @@ class EventConfirmation implements EntryPoint $action = $request->getQueryParam('action') ?? null; if (!$uid) { - throw new BadRequest(); + throw new BadRequest("No uid."); } if (!in_array($action, [self::ACTION_ACCEPT, self::ACTION_DECLINE, self::ACTION_TENTATIVE])) { - throw new BadRequest(); + throw new BadRequest("Bad action."); } /** @var ?UniqueId $uniqueId */ @@ -112,11 +112,11 @@ class EventConfirmation implements EntryPoint $link; if (!$toProcess) { - throw new Error(); + throw new Error("Bad data."); } if ($sentDateStart !== null && !is_string($sentDateStart)) { - throw new Error(); + throw new Error("No date in data."); } $event = $this->entityManager->getEntityById($eventType, $eventId); diff --git a/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php b/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php index aa2d9d9292..fa863d8e90 100644 --- a/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php +++ b/application/Espo/Modules/Crm/EntryPoints/SubscribeAgain.php @@ -81,7 +81,7 @@ class SubscribeAgain implements EntryPoint } if (!$id || !is_string($id)) { - throw new BadRequest(); + throw new BadRequest("No id."); } $queueItemId = $id; @@ -90,7 +90,7 @@ class SubscribeAgain implements EntryPoint $queueItem = $this->entityManager->getEntity(EmailQueueItem::ENTITY_TYPE, $queueItemId); if (!$queueItem) { - throw new NotFound(); + throw new NotFound("No item."); } $campaign = null; @@ -116,7 +116,7 @@ class SubscribeAgain implements EntryPoint $target = $this->entityManager->getEntityById($targetType, $targetId); if (!$target) { - throw new NotFound(); + throw new NotFound("Record not found."); } if ($massEmail->get('optOutEntirely')) { diff --git a/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php b/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php index d0328cdaa6..a3469fbfc9 100644 --- a/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php +++ b/application/Espo/Modules/Crm/EntryPoints/Unsubscribe.php @@ -84,7 +84,7 @@ class Unsubscribe implements EntryPoint } if (!$id) { - throw new BadRequest(); + throw new BadRequest("No id."); } $queueItemId = $id; @@ -93,7 +93,7 @@ class Unsubscribe implements EntryPoint $queueItem = $this->entityManager->getEntityById(EmailQueueItem::ENTITY_TYPE, $queueItemId); if (!$queueItem) { - throw new NotFound(); + throw new NotFound("No item."); } $campaign = null; diff --git a/application/Espo/Tools/Stream/Api/PostFollowers.php b/application/Espo/Tools/Stream/Api/PostFollowers.php index dc62454f51..7aa1fcad45 100644 --- a/application/Espo/Tools/Stream/Api/PostFollowers.php +++ b/application/Espo/Tools/Stream/Api/PostFollowers.php @@ -56,11 +56,11 @@ class PostFollowers implements Action $data = $request->getParsedBody(); if (!$entityType || !$id) { - throw new BadRequest(); + throw new BadRequest("No entityType or id."); } if (!$this->acl->check($entityType)) { - throw new Forbidden(); + throw new Forbidden("No access to $entityType."); } $ids = $data->ids ?? (isset($data->id) ? [$data->id] : []);