diff --git a/application/Espo/ORM/Collection.php b/application/Espo/ORM/Collection.php index 10083d33e7..4221187c03 100644 --- a/application/Espo/ORM/Collection.php +++ b/application/Espo/ORM/Collection.php @@ -36,7 +36,7 @@ use stdClass; * A collection of entities. * * @template TValue of Entity - * @extends Traversable + * @bypass-extends Traversable * * @todo Extend from Traversable once the min supported PHP version is 7.4. Remove bypass. */ diff --git a/application/Espo/ORM/Locker/MysqlLocker.php b/application/Espo/ORM/Locker/MysqlLocker.php index be0f9a0b2f..a14f9beb5f 100644 --- a/application/Espo/ORM/Locker/MysqlLocker.php +++ b/application/Espo/ORM/Locker/MysqlLocker.php @@ -29,9 +29,10 @@ namespace Espo\ORM\Locker; +use Espo\ORM\QueryComposer\MysqlQueryComposer; + use Espo\ORM\{ TransactionManager, - QueryComposer\QueryComposer, Query\LockTableBuilder, }; @@ -51,7 +52,7 @@ class MysqlLocker implements Locker private $isLocked = false; - public function __construct(PDO $pdo, QueryComposer $queryComposer, TransactionManager $transactionManager) + public function __construct(PDO $pdo, MysqlQueryComposer $queryComposer, TransactionManager $transactionManager) { $this->pdo = $pdo; $this->queryComposer = $queryComposer; diff --git a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php index 77e3450ecf..3ccba17467 100644 --- a/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php +++ b/application/Espo/ORM/Repository/RDBRelationSelectBuilder.php @@ -164,9 +164,7 @@ class RDBRelationSelectBuilder { $transformedWhere = []; - $middleName = lcfirst( - $this->entity->getRelationParam($this->relationName, 'relationName') - ); + $middleName = lcfirst($this->getRelationParam('relationName')); foreach ($where as $key => $value) { $transformedKey = $key; @@ -429,7 +427,7 @@ class RDBRelationSelectBuilder } if (!$this->middleTableAlias) { - $middleName = $this->entity->getRelationParam($this->relationName, 'relationName'); + $middleName = $this->getRelationParam('relationName'); if (!$middleName) { throw new RuntimeException("No relation name."); @@ -495,4 +493,24 @@ class RDBRelationSelectBuilder return $this->entityManager->getCollectionFactory()->createFromSthCollection($collection); } + + /** + * @return mixed + */ + private function getRelationParam(string $param) + { + if ($this->entity instanceof BaseEntity) { + return $this->entity->getRelationParam($this->relationName, $param); + } + + $entityDefs = $this->entityManager + ->getDefs() + ->getEntity($this->entity->getEntityType()); + + if (!$entityDefs->hasRelation($this->relationName)) { + return null; + } + + return $entityDefs->getRelation($this->relationName)->getParam($param); + } }