-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths #54271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -141,8 +141,10 @@ public function guessMaxLength(string $class, string $property) | |||
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) { | |||
$mapping = $ret[0]->getFieldMapping($property); | |||
|
|||
if (isset($mapping['length'])) { | |||
return new ValueGuess($mapping['length'], Guess::HIGH_CONFIDENCE); | |||
$length = \is_array($mapping) ? $mapping['length'] : $mapping->length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous logic allowed the length
key not to be set. Your code would trigger a warning in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we tested for the actual class instead?
$length = $mapping instanceof FieldMapping ? $mapping->length : ($mapping['length'] ?? null);
Thank you @eltharin. |
9aed443
to
43d9c19
Compare
[DoctrineBridge] prevent deprecated message #54255 for symfony 5.4