diff --git a/application/Espo/Entities/Note.php b/application/Espo/Entities/Note.php index 7f2ddef52d..420d453389 100644 --- a/application/Espo/Entities/Note.php +++ b/application/Espo/Entities/Note.php @@ -147,7 +147,7 @@ class Note extends Entity $attachmentsIds = $data->attachmentsIds; $collection = $this->entityManager - ->getRepository('Attachment') + ->getRDBRepository('Attachment') ->select(['id', 'name', 'type']) ->order('createdAt') ->where([ diff --git a/application/Espo/EntryPoints/Avatar.php b/application/Espo/EntryPoints/Avatar.php index b2196c9ce4..9157a4c9e4 100644 --- a/application/Espo/EntryPoints/Avatar.php +++ b/application/Espo/EntryPoints/Avatar.php @@ -79,9 +79,8 @@ class Avatar extends Image implements Di\MetadataAware public function run(Request $request, Response $response): void { - $userId = $request->get('id'); - - $size = $request->get('size') ?? null; + $userId = $request->getQueryParam('id'); + $size = $request->getQueryParam('size') ?? null; if (!$userId) { throw new BadRequest(); diff --git a/application/Espo/EntryPoints/ConfirmOptIn.php b/application/Espo/EntryPoints/ConfirmOptIn.php index f0d514d8f4..d4c88f935c 100644 --- a/application/Espo/EntryPoints/ConfirmOptIn.php +++ b/application/Espo/EntryPoints/ConfirmOptIn.php @@ -57,7 +57,7 @@ class ConfirmOptIn implements EntryPoint public function run(Request $request, Response $response): void { - $id = $request->get('id'); + $id = $request->getQueryParam('id'); if (!$id) { throw new BadRequest(); diff --git a/application/Espo/EntryPoints/LogoImage.php b/application/Espo/EntryPoints/LogoImage.php index 1505c2bcea..909999b23e 100644 --- a/application/Espo/EntryPoints/LogoImage.php +++ b/application/Espo/EntryPoints/LogoImage.php @@ -49,8 +49,8 @@ class LogoImage extends Image implements Di\ConfigAware public function run(Request $request, Response $response): void { - $id = $request->get('id'); - $size = $request->get('size') ?? null; + $id = $request->getQueryParam('id'); + $size = $request->getQueryParam('size') ?? null; if (!$id) { $id = $this->config->get('companyLogoId'); diff --git a/application/Espo/EntryPoints/Pdf.php b/application/Espo/EntryPoints/Pdf.php index fbeb67a36d..24112bf1b1 100644 --- a/application/Espo/EntryPoints/Pdf.php +++ b/application/Espo/EntryPoints/Pdf.php @@ -87,7 +87,7 @@ class Pdf implements EntryPoint ->setHeader('Content-Disposition', 'inline; filename="' . basename($fileName) . '"'); if (!$request->getServerParam('HTTP_ACCEPT_ENCODING')) { - $response->setHeader('Content-Length', $contents->getLength()); + $response->setHeader('Content-Length', strlen($contents)); } $response->writeBody($contents); diff --git a/application/Espo/Hooks/Common/WebSocketSubmit.php b/application/Espo/Hooks/Common/WebSocketSubmit.php index 13a5a1d453..c838143870 100644 --- a/application/Espo/Hooks/Common/WebSocketSubmit.php +++ b/application/Espo/Hooks/Common/WebSocketSubmit.php @@ -69,7 +69,7 @@ class WebSocketSubmit } $scope = $entity->getEntityType(); - $id = $entity->id; + $id = $entity->getId(); if (!$this->metadata->get(['scopes', $scope, 'object'])) { return; diff --git a/application/Espo/Hooks/Integration/GoogleMaps.php b/application/Espo/Hooks/Integration/GoogleMaps.php index 6c611136cf..b23e718745 100644 --- a/application/Espo/Hooks/Integration/GoogleMaps.php +++ b/application/Espo/Hooks/Integration/GoogleMaps.php @@ -31,22 +31,27 @@ namespace Espo\Hooks\Integration; use Espo\ORM\Entity; +use Espo\Entities\Integration; + use Espo\Core\{ Utils\Config\ConfigWriter, }; class GoogleMaps { - protected $configWriter; + private $configWriter; public function __construct(ConfigWriter $configWriter) { $this->configWriter = $configWriter; } + /** + * @param Integration $entity + */ public function afterSave(Entity $entity) { - if ($entity->id !== 'GoogleMaps') { + if ($entity->getId() !== 'GoogleMaps') { return; } diff --git a/application/Espo/Hooks/Portal/WriteConfig.php b/application/Espo/Hooks/Portal/WriteConfig.php index 1d20f4f64a..f801b93e0e 100644 --- a/application/Espo/Hooks/Portal/WriteConfig.php +++ b/application/Espo/Hooks/Portal/WriteConfig.php @@ -31,6 +31,8 @@ namespace Espo\Hooks\Portal; use Espo\ORM\Entity; +use Espo\Entities\Portal; + use Espo\Core\{ Utils\Config, Utils\Config\ConfigWriter, @@ -38,9 +40,9 @@ use Espo\Core\{ class WriteConfig { - protected $config; + private $config; - protected $configWriter; + private $configWriter; public function __construct(Config $config, ConfigWriter $configWriter) { @@ -48,6 +50,9 @@ class WriteConfig $this->configWriter = $configWriter; } + /** + * @param Portal $entity + */ public function afterSave(Entity $entity) { if (!$entity->has('isDefault')) { @@ -57,17 +62,16 @@ class WriteConfig if ($entity->get('isDefault')) { $defaultPortalId = $this->config->get('defaultPortalId'); - if ($defaultPortalId === $entity->id) { + if ($defaultPortalId === $entity->getId()) { return; } - $this->configWriter->set('defaultPortalId', $entity->id); + $this->configWriter->set('defaultPortalId', $entity->getId()); $this->configWriter->save(); } if ($entity->isAttributeChanged('isDefault') && $entity->getFetched('isDefault')) { - $this->configWriter->set('defaultPortalId', null); $this->configWriter->save(); diff --git a/application/Espo/Hooks/User/ApiKey.php b/application/Espo/Hooks/User/ApiKey.php index f68d945e6c..e8aad8c378 100644 --- a/application/Espo/Hooks/User/ApiKey.php +++ b/application/Espo/Hooks/User/ApiKey.php @@ -31,19 +31,22 @@ namespace Espo\Hooks\User; use Espo\ORM\Entity; -use Espo\Core\{ - Utils\ApiKey as ApiKeyUtil, -}; +use Espo\Core\Utils\ApiKey as ApiKeyUtil; + +use Espo\Entities\User; class ApiKey { - protected $apiKey; + private $apiKey; public function __construct(ApiKeyUtil $apiKey) { $this->apiKey = $apiKey; } + /** + * @param User $entity + */ public function afterSave(Entity $entity) { if (!$entity->isApi()) { @@ -57,17 +60,20 @@ class ApiKey $entity->isAttributeChanged('authMethod') ) ) { - $this->apiKey->storeSecretKeyForUserId($entity->id, $entity->get('secretKey')); + $this->apiKey->storeSecretKeyForUserId($entity->getId(), $entity->get('secretKey')); } if ( $entity->isAttributeChanged('authMethod') && $entity->get('authMethod') !== 'Hmac' ) { - $this->apiKey->removeSecretKeyForUserId($entity->id); + $this->apiKey->removeSecretKeyForUserId($entity->getId()); } } + /** + * @param User $entity + */ public function afterRemove(Entity $entity) { if (!$entity->isApi()) { @@ -75,7 +81,7 @@ class ApiKey } if ($entity->isApi() && $entity->get('authMethod') === 'Hmac') { - $this->apiKey->removeSecretKeyForUserId($entity->id); + $this->apiKey->removeSecretKeyForUserId($entity->getId()); } } } diff --git a/application/Espo/Modules/Crm/Classes/Acl/Call/AccessChecker.php b/application/Espo/Modules/Crm/Classes/Acl/Call/AccessChecker.php index 035deb4a04..83a6b537ce 100644 --- a/application/Espo/Modules/Crm/Classes/Acl/Call/AccessChecker.php +++ b/application/Espo/Modules/Crm/Classes/Acl/Call/AccessChecker.php @@ -33,6 +33,8 @@ use Espo\Entities\User; use Espo\ORM\Entity; +use Espo\Core\ORM\Entity as CoreEntity; + use Espo\Core\{ Acl\ScopeData, Acl\Table, @@ -58,6 +60,8 @@ class AccessChecker implements AccessEntityCREDSChecker return true; } + assert($entity instanceof CoreEntity); + if ($data->getRead() === Table::LEVEL_OWN || $data->getRead() === Table::LEVEL_TEAM) { if ($entity->hasLinkMultipleId('users', $user->getId())) { return true; diff --git a/application/Espo/Modules/Crm/Classes/Acl/Meeting/AccessChecker.php b/application/Espo/Modules/Crm/Classes/Acl/Meeting/AccessChecker.php index c5c4c3fbb9..b894753a9f 100644 --- a/application/Espo/Modules/Crm/Classes/Acl/Meeting/AccessChecker.php +++ b/application/Espo/Modules/Crm/Classes/Acl/Meeting/AccessChecker.php @@ -33,6 +33,8 @@ use Espo\Entities\User; use Espo\ORM\Entity; +use Espo\Core\ORM\Entity as CoreEntity; + use Espo\Core\{ Acl\ScopeData, Acl\Table, @@ -58,6 +60,8 @@ class AccessChecker implements AccessEntityCREDSChecker return true; } + assert($entity instanceof CoreEntity); + if ($data->getRead() === Table::LEVEL_OWN || $data->getRead() === Table::LEVEL_TEAM) { if ($entity->hasLinkMultipleId('users', $user->getId())) { return true; diff --git a/application/Espo/Modules/Crm/Classes/AclPortal/KnowledgeBaseArticle/AccessChecker.php b/application/Espo/Modules/Crm/Classes/AclPortal/KnowledgeBaseArticle/AccessChecker.php index da72ae64f9..9c46994ce7 100644 --- a/application/Espo/Modules/Crm/Classes/AclPortal/KnowledgeBaseArticle/AccessChecker.php +++ b/application/Espo/Modules/Crm/Classes/AclPortal/KnowledgeBaseArticle/AccessChecker.php @@ -33,6 +33,8 @@ use Espo\Entities\User; use Espo\ORM\Entity; +use Espo\Core\ORM\Entity as CoreEntity; + use Espo\Core\{ Acl\ScopeData, Acl\AccessEntityCREDChecker, @@ -61,6 +63,8 @@ class AccessChecker implements AccessEntityCREDChecker return false; } + assert($entity instanceof CoreEntity); + $portalIdList = $entity->getLinkMultipleIdList('portals'); $portalId = $user->get('portalId'); diff --git a/application/Espo/Modules/Crm/Classes/FieldProcessing/Call/PhoneNumberMapLoader.php b/application/Espo/Modules/Crm/Classes/FieldProcessing/Call/PhoneNumberMapLoader.php index 192972743e..009d5f17f4 100644 --- a/application/Espo/Modules/Crm/Classes/FieldProcessing/Call/PhoneNumberMapLoader.php +++ b/application/Espo/Modules/Crm/Classes/FieldProcessing/Call/PhoneNumberMapLoader.php @@ -31,13 +31,15 @@ namespace Espo\Modules\Crm\Classes\FieldProcessing\Call; use Espo\ORM\Entity; +use Espo\Core\ORM\Entity as CoreEntity; + use Espo\Core\{ FieldProcessing\Loader, FieldProcessing\Loader\Params, ORM\EntityManager, }; -use StdClass; +use stdClass; class PhoneNumberMapLoader implements Loader { @@ -54,6 +56,8 @@ class PhoneNumberMapLoader implements Loader { $map = (object) []; + assert($entity instanceof CoreEntity); + $contactIdList = $entity->getLinkMultipleIdList('contacts'); if (count($contactIdList)) { @@ -69,7 +73,7 @@ class PhoneNumberMapLoader implements Loader $entity->set('phoneNumbersMap', $map); } - private function populate(StdClass $map, string $entityType, array $idList): void + private function populate(stdClass $map, string $entityType, array $idList): void { $entityList = $this->entityManager ->getRDBRepository($entityType) diff --git a/application/Espo/Modules/Crm/Classes/FieldProcessing/TargetList/OptedOutCountLoader.php b/application/Espo/Modules/Crm/Classes/FieldProcessing/TargetList/OptedOutCountLoader.php index f94eeba502..a440399675 100644 --- a/application/Espo/Modules/Crm/Classes/FieldProcessing/TargetList/OptedOutCountLoader.php +++ b/application/Espo/Modules/Crm/Classes/FieldProcessing/TargetList/OptedOutCountLoader.php @@ -31,6 +31,8 @@ namespace Espo\Modules\Crm\Classes\FieldProcessing\TargetList; use Espo\ORM\Entity; +use Espo\Modules\Crm\Entities\TargetList; + use Espo\Core\{ FieldProcessing\Loader, FieldProcessing\Loader\Params, @@ -57,6 +59,8 @@ class OptedOutCountLoader implements Loader return; } + assert($entity instanceof TargetList); + $count = 0; foreach ($this->targetsLinkList as $link) {