8000 [DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths by eltharin · Pull Request #54271 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

eltharin
Copy link
Contributor
Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues
License MIT

[DoctrineBridge] prevent deprecated message #54255 for symfony 5.4

@@ -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;
Copy link
Member

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.

Copy link
Member

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);

@derrabus derrabus changed the title [DoctrineBridge] prevent deprecated message for ORM > 3.1 for Symfony 5.4 [DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths Mar 13, 2024
@fabpot
Copy link
BC26
Member
fabpot commented Mar 17, 2024

Thank you @eltharin.

@fabpot fabpot force-pushed the doctrineormdeprecation branch from 9aed443 to 43d9c19 Compare March 17, 2024 14:56
@fabpot fabpot merged commit 2ce3e04 into symfony:5.4 Mar 17, 2024
@eltharin eltharin deleted the doctrineormdeprecation branch March 17, 2024 15:22
This was referenced Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0