Skip to content
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

Fix compatibility issues with doctrine/orm package version 3 #465

Merged
merged 5 commits into from
Feb 12, 2025

Conversation

lxix
Copy link
Contributor

@lxix lxix commented Nov 26, 2024

Hey,

This PR is aiming at doctrine/orm 3 support, while dropping version 2. (Similar to #460 )

Hope you like it, suggestions welcomed!

@lxix lxix marked this pull request as ready for review November 26, 2024 19:01
@lxix lxix marked this pull request as draft November 26, 2024 19:11
@lxix lxix marked this pull request as ready for review November 26, 2024 19:20
* @return int
*/
public function count(array $locales = null, array $filters = null)
public function count(array $criteria = []): int
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would you replace explicit function arguments by an array that leaves people guessing what is intended?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it a requirement of the updated components?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is how it's done in the super class. This breaks compatibility with v2. https://github.com/doctrine/orm/blob/c9557c588b3a70ed93caff069d0aa75737f25609/src/EntityRepository.php#L138

{
$this->loadCustomHydrator();

$builder = $this->createQueryBuilder('tu')
->select('COUNT(DISTINCT tu.id) AS number');

$locales = $criteria['locales'] ?? null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

And then need to more lines to extract what was already there?

Copy link
Contributor Author

@lxix lxix Feb 11, 2025

Choose a reason for hiding this comment

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

Sadly, this is the workaround (mentioned previously)

@@ -14,11 +14,11 @@ class SingleColumnArrayHydrator extends AbstractHydrator
/**
* {@inheritdoc}
*/
protected function hydrateAllData()
protected function hydrateAllData(): mixed
Copy link
Collaborator

Choose a reason for hiding this comment

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

mixed as a return type doesn't add much value, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bartmcleod
Copy link
Collaborator

bartmcleod commented Feb 10, 2025

@lxix Can you solve the conflicts maybe, it seems I have merged a PR that has a similar goal, but does not go as far as you do and your solution might be better... Please have a look at my comments as well, maybe I just don't get everything you want to do.

@bartmcleod bartmcleod self-assigned this Feb 10, 2025
@lxix
Copy link
Contributor Author

lxix commented Feb 11, 2025

@bartmcleod Thanks for you feedback, i'll look into it once I have free time again.

Update: Done, conflicts resolved

@lxix lxix force-pushed the bump-doctrine-orm branch from c219bb8 to e3fc1c0 Compare February 11, 2025 20:24
@bartmcleod
Copy link
Collaborator

bartmcleod commented Feb 11, 2025

@lxix Thanks for your explanations and updates. I have ran the Github action. As you can see, they failed. The next time you push, the action will run automatically, so it will be easier for you to verify that it is correct. I hope you will find the time to fix the errors.

@bartmcleod
Copy link
Collaborator

@lxix I have been able to fix 26 of the 27 errors, in case you have not started yet on those

@bartmcleod
Copy link
Collaborator

bartmcleod commented Feb 11, 2025

@lxix The last remaining error seems to be internal to one of the Doctrine packages. We can probably not fix that, unless we fix that package. So we could either skip the import test until that is fixed or remain stuck, unless you know of another solution maybe. Could be it is possible to configure an EntityManagerProvider and then it might be magically injected...

@lxix
Copy link
Contributor Author

lxix commented Feb 12, 2025

@bartmcleod I've replaced the deprecated CreateSchemaDoctrineCommand and DropSchemaDoctrineCommand with the recommended ones. Also, maybe this way we can get EntityManagerProvider out of the container. Could you approve the workflow for me as it did not run automatically?

@bartmcleod
Copy link
Collaborator

bartmcleod commented Feb 12, 2025

@lxix I pulled the changes and ran the tests locally, it now gives

There was 1 error:

1) Lexik\Bundle\TranslationBundle\Tests\Command\ImportTranslationsCommandTest::testExecute
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: The "doctrine.orm.command.entity_manager_provider" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

@bartmcleod
Copy link
Collaborator

bartmcleod commented Feb 12, 2025

@lxix I managed to fix it. It looks a bit clunky, but the test is happy, please test it once more in the UI and the commands and if you are happy, let me know and I will merge it. I must create a v7.0.3 tag on master first to have a fixed point before this bc break.

@lxix
Copy link
Contributor Author

lxix commented Feb 12, 2025

@bartmcleod Good news! Thanks for your time and assistance

@bartmcleod
Copy link
Collaborator

@lxix You are most welcome, thanks for starting this improvement and your persistence!

@bartmcleod
Copy link
Collaborator

I just saw we already have a 7.1 tag, so we can safely proceed with the merge when you are happy and tag it v7.2

@lxix
Copy link
Contributor Author

lxix commented Feb 12, 2025

I ran a few quick manual tests on symfony 7.1 and doctrine/orm 3.3.2 (this is the latest I have right now). UI functionality seems OK. I will test it with 7.2 in the near future.

@bartmcleod bartmcleod merged commit d03c25a into lexik:master Feb 12, 2025
1 check passed
@bartmcleod
Copy link
Collaborator

Ah, yes, I was under the impression that I was using 7.2, but in fact it is 7.1.5. I also see no errors in the UI and the commands.

@lxix lxix deleted the bump-doctrine-orm branch February 13, 2025 15:21
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.

2 participants