Skip to content

Commit 8add1b4

Browse files
committedMar 4, 2025
bug #6850 fix(chore): resolve problem of inherit attribute (jorisdugue)
This PR was squashed before being merged into the 4.x branch. Discussion ---------- fix(chore): resolve problem of inherit attribute fix #6849 #6853 This pull request addresses an issue where EasyAdmin fails to handle inherited properties during global search. Specifically, the issue arises when EasyAdmin tries to reflect on a property that exists in a parent class but not in the current class. The current implementation of property reflection does not account for inherited properties in parent classes, leading to errors when performing a global search. Commits ------- 62fb2b4 fix(chore): resolve problem of inherit attribute
2 parents 4d1ae6b + 62fb2b4 commit 8add1b4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
 

‎src/Orm/EntityRepository.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,22 @@ private function getSearchablePropertiesConfig(QueryBuilder $queryBuilder, Searc
309309
? $associatedEntityDto->getFqcn()
310310
: $entityDto->getFqcn()
311311
;
312+
312313
/** @var \ReflectionNamedType|\ReflectionUnionType|null $idClassType */
313-
$idClassType = (new \ReflectionProperty($entityFqcn, $propertyName))->getType();
314+
$idClassType = null;
315+
$reflectionClass = new \ReflectionClass($entityFqcn);
316+
317+
while (false !== $reflectionClass) {
318+
if ($reflectionClass->hasProperty($propertyName)) {
319+
$reflection = $reflectionClass->getProperty($propertyName);
320+
$idClassType = $reflection->getType();
321+
break;
322+
}
323+
$reflectionClass = $reflectionClass->getParentClass();
324+
}
314325

315326
if (null !== $idClassType) {
327+
/** @var \ReflectionNamedType|\ReflectionUnionType|null $idClassType */
316328
$idClassName = $idClassType->getName();
317329

318330
if (class_exists($idClassName)) {

0 commit comments

Comments
 (0)
Please sign in to comment.