Open ngocongcan opened 6 years ago
can you please add more details? like the full exception, your class code and your json document that caused the error.
Thanks for your response. I think you can check line 79 of class DoctrineObjectConstructor
$dataName = $namingStrategy->translateName($metadata->propertyMetadata[$name]);
There is no check if $metadata->propertyMetadata[$name] exist.
can you please add more details? like the full exception, your class code and your json document that caused the error.
The problem is on line 79. This is from 1.13:
foreach ($classMetadata->getIdentifierFieldNames() as $name) {
if ($visitor instanceof AbstractVisitor) {
/** @var PropertyNamingStrategyInterface $namingStrategy */
$namingStrategy = $visitor->getNamingStrategy();
$dataName = $namingStrategy->translateName($metadata->propertyMetadata[$name]);
} else {
$dataName = $name;
}
if (!array_key_exists($dataName, $data)) {
return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
}
$identifierList[$name] = $data[$dataName];
}
If there is no name present in doctrine's column annotation it might trigger an error at $metadata->propertyMetadata[$name]
.
In my case, it is triggered when using the DoctrineObjectConstructor with the ObjectConstructor fallback strategy and a custom IdGenerator. Probably not relevant however.
Steps required to reproduce the problem
Expected Result
Actual Result
Suggestion
Why we remove check isset($metadata->propertyMetadata[$name]) before access it on v1.13.0 ? It causes error on the project which was using v1.11.0 (still checking ) Now, once updating we have to add the annotation before all identify fields. Could we add
isset($metadata->propertyMetadata[$name])
before accessing on DoctrineObjectConstructor?Thanks!