Skip to content

Commit 0e8890b

Browse files
committed
Prevent reading from proxy class
1 parent 1188cbb commit 0e8890b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Watcher/EventListener/FlushListener.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\Common\Annotations\CachedReader;
66
use Doctrine\Common\Annotations\Reader;
7+
use Doctrine\Common\Util\ClassUtils;
78
use Doctrine\ORM\Event\OnFlushEventArgs;
89
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
910
use Watcher\Annotations\WatchedField;
@@ -135,7 +136,9 @@ private function getWatchedFieldAnnotation(Reader $reader, WatchedEntity $entity
135136
$field = substr($field, 0, $dotPosition);
136137
}
137138

138-
$reflectionProperty = new \ReflectionProperty(get_class($entity), $field);
139+
// Do not use a proxied class
140+
$realClass = ClassUtils::getClass($entity);
141+
$reflectionProperty = new \ReflectionProperty($realClass, $field);
139142

140143
$propertyAnnotations = $reader->getPropertyAnnotations($reflectionProperty);
141144
foreach ($propertyAnnotations as $annotation) {

0 commit comments

Comments
 (0)