Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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