Skip to content

[DoctrineBridge] prevent deprecated message #54255

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

Closed
wants to merge 1 commit into from
Closed

Conversation

eltharin
Copy link
Contributor

@eltharin eltharin commented Mar 12, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues
License MIT

prevent this deprecation :
User Deprecated: Using ArrayAccess on Doctrine\ORM\Mapping\FieldMapping is deprecated and will not be possible in Doctrine ORM 4.0. Use the corresponding property instead. (ArrayAccessImplementation.php:18 called by DoctrineOrmTypeGuesser.php:132, doctrine/orm#11211, package doctrine/orm)

same as symfony/doctrine-bridge#15

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.4" but it seems your PR description refers to branch "6.4,".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@nicolas-grekas
Copy link
Member

I rebased the PR for 5.4 where the issue exists. It's strange that we didn't notice the deprecation before. It likely means that this code path is not tested. Could you please have a look and add a test case if none covers this line?

@eltharin
Copy link
Contributor Author

Problem with V5.4 is compatible with Doctrine/Orm < 2.10.3 where change was made,

For 5.4, it would be necessary to test if the return is an array or an object, per example :

    $length = is_array($mapping) ? $mapping['length'] : $mapping->length;

    if (isset($length)) {
        return new ValueGuess($length, Guess::HIGH_CONFIDENCE);
    }

For information, I have this deprecation after update Orm to V3.1 directly when a form based on an entity was handled :

        $form = $this->createForm(TestType::class, new Test());

        $form->handleRequest($request);

I will try to add a test.

@nicolas-grekas nicolas-grekas changed the base branch from 5.4 to 6.4 March 13, 2024 11:31
@nicolas-grekas
Copy link
Member

Thanks. Yes, we'd need this "is_array" test indeed on 5.4.
Note that we don't merge PRs with merge commits in them so you'd need to squash or revert --hard to the previous commit (I'm not sure the merge commit is needed).
Note for your next PR: it's better to create dedicated feature branches instead of committing to your "6.4" directly ;)
Let me know if you need help.
Thanks for the tests!

@eltharin
Copy link
Contributor Author

I saw that, sorry :)
for 5.4 you made the changes?

@nicolas-grekas nicolas-grekas changed the base branch from 6.4 to 5.4 March 13, 2024 11:45
@nicolas-grekas nicolas-grekas changed the base branch from 5.4 to 6.4 March 13, 2024 11:45
@nicolas-grekas
Copy link
Member

I didn't, please add them and I'll take care of the rebase/retarget for 5.4 before merging.

@eltharin
Copy link
Contributor Author

made it in #54271

Comment on lines 1779 to 1781
set_error_handler(static function (int $errno, string $errstr) use (&$deprecation) {
$deprecation[] = $errstr;
}, E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not need a dedicated error handler for deprecations. Our error handler should make our tests fail if they trigger a deprecation. In other words: test the functionality, not the deprecation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so delete the test, the test for this fonctionnality already exists,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delete it

@eltharin eltharin requested a review from derrabus March 13, 2024 14:26
@derrabus
Copy link
Member

Closing in favor of #54271 then.

@derrabus derrabus closed this Mar 13, 2024
fabpot added a commit that referenced this pull request Mar 17, 2024
…uessing field lengths (eltharin)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths

| 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

Commits
-------

43d9c19 [DoctrineBridge] Fix deprecation warning with ORM 3 when guessing field lengths
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.

4 participants