Skip to content

Doctrine Upgrade#2026

Merged
BentiGorlich merged 10 commits intomainfrom
new/doctrine-upgrade
Mar 18, 2026
Merged

Doctrine Upgrade#2026
BentiGorlich merged 10 commits intomainfrom
new/doctrine-upgrade

Conversation

@BentiGorlich
Copy link
Copy Markdown
Member

@BentiGorlich BentiGorlich commented Feb 18, 2026

This upgrades the doctrine stack (dbal, orm, migrations, etc.):

  - Removing doctrine/common (3.5.0)
  - Removing doctrine/cache (2.2.0)
  - Removing doctrine/annotations (2.0.2)
  - Upgrading doctrine/event-manager (2.0.1 => 2.1.1)
  - Upgrading doctrine/persistence (3.4.3 => 4.1.1)
  - Upgrading doctrine/sql-formatter (1.5.3 => 1.5.4)
  - Upgrading doctrine/deprecations (1.1.5 => 1.1.6)
  - Upgrading doctrine/dbal (3.10.3 => 4.4.2)
  - Upgrading doctrine/doctrine-bundle (2.18.1 => 2.18.2)
  - Upgrading doctrine/collections (2.4.0 => 2.6.0)
  - Upgrading doctrine/orm (2.20.8 => 3.6.2)
  - Upgrading doctrine/doctrine-fixtures-bundle (3.7.2 => 4.3.1)
  - Upgrading doctrine/migrations (3.9.4 => 3.9.6)
  - Upgrading doctrine/doctrine-migrations-bundle (3.6.0 => 3.7.0)

This kind of supersedes #1873, @blued-gear will create a follow-up PR to commit the migration improvements

@BentiGorlich BentiGorlich self-assigned this Feb 18, 2026
@BentiGorlich BentiGorlich added enhancement New feature or request dependencies Pull requests that update a dependency file labels Feb 18, 2026
@BentiGorlich
Copy link
Copy Markdown
Member Author

This branch is put on top of a rebased branch from #1968
After that is merged this will be rebased on main and only the last commit will remain

@BentiGorlich
Copy link
Copy Markdown
Member Author

Seems like I now added a php-version requirement again. Will look into that

@blued-gear
Copy link
Copy Markdown
Collaborator

I compared this PR with #1873 and listed some changes you can consider adding here:

https://github.com/MbinOrg/mbin/pull/1873/changes#diff-0cd17fe36ca4ce7848f6b41e323f48a41c84ea073abbaf1990f086cb33b26a0a
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-cc2064b45d18bb3fec1f9857bc93d6fbaae1dfe37843360848c660a7dcbc917dR52
-> you changed the constructor param; I don't know why this wasn't possible in my branch, but if an issue comes up with the changed constructor, this might help
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-20b02bfd14392cbeea96ad010f5354a601777c02d8817717f34499dc3e43fc7b
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-d78c37a892e5e020ef1c0882dc24a8d54d4f70d6904e35264e228692fb2e7199
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-c1d37559aa251754682b2e972c2eef2018b93e96aa35730a6a2e73363b210fc4
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-4bfd5f2ecde4ae6c13f833bb8098b809f1077a3a7d54756f3165c35d3511c457
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-22ea07dc188b31ff2c4f42c99ef9b39e2047194af49fbfa05ecbde6ca5f2a1a9
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-29168649467ab681a1c7891011f17d64e2cae8a6efd8f976111521bb308ea372R107
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-29168649467ab681a1c7891011f17d64e2cae8a6efd8f976111521bb308ea372R127
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-29168649467ab681a1c7891011f17d64e2cae8a6efd8f976111521bb308ea372R151
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-29168649467ab681a1c7891011f17d64e2cae8a6efd8f976111521bb308ea372R153
-> this needs a migration
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-29168649467ab681a1c7891011f17d64e2cae8a6efd8f976111521bb308ea372R257
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-155cae8f95b57443b14def8472fbbf35448b0136267c793d84c58516acf0375f
-> I forgot why this was removed, but it might had a reason
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-762436a2a47102c700d35c6467934b65c3a889ef1292369ac246fdc025c0547f
-> you might not need to inject the EntityManager
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-4ff10f21fcc5485911c5f518e346c585b153760866b6c9717c4a568f802fe1f1R325
-> same here
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-99d4e4bd7513bfd0347ae9270c6f8a746e093a4397edf0bb2a9274e9030d5b98
-> same here
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-570b03bf9e439e5907eeec856e1e967aaecd20065ed955fc65209ddaca32fcf0
-> same here
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-33d8ea5251ce13dbcece5648bf18cf13226b449937edbcd214eecd01f0fcd7d8
-> same here
... and so on

Some other things which were deprecations or warnings or PhpStrom recommendations:
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-0bf7eadae16c9bca989d87cdb3150793d7ab06bfa8ae82fb87653a3e0ec7e5cf
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-dddf3bbc5ad401e16d7901ff9b4f1870d436414ca70a942273694126563166c9
https://github.com/MbinOrg/mbin/pull/1873/changes#diff-9e80731da409be5eaad08118258b9326ee1cbb2a0ff0507b9cf58018e227eaa7

@BentiGorlich
Copy link
Copy Markdown
Member Author

Ok, so I removed all entity manager injections in the repositories that do not need it, I executed the migrations diff command, but all I got was a whole lot of ADD COMMENT \'\' which is useless imo.

@BentiGorlich BentiGorlich marked this pull request as ready for review March 3, 2026 12:29
@blued-gear
Copy link
Copy Markdown
Collaborator

but all I got was a whole lot of ADD COMMENT '' which is useless imo.

I have these too sometimes. I guess that Doctrine uses comments to store some metadata about the generated structures. But I don't think, they are necessary. If everything works after the upgrade, including applying migrations, then I think we can ignore them.

@BentiGorlich
Copy link
Copy Markdown
Member Author

Yeah generating the diff works. There is a lot in it that is not useful, but my goal was to upgrade doctrine and improve the generated migrations afterwards. Do you agree with that?

@blued-gear
Copy link
Copy Markdown
Collaborator

If nothing is broken, then there is no problem. For the time being we can remove the comment statements from new generated migrations by hand (or just let them be, I don't know what is better for them).

@blued-gear
Copy link
Copy Markdown
Collaborator

Will you revert your downgrades for PHP 8.3 as we will upgrade anyway or is this planned for a later PR?

@BentiGorlich
Copy link
Copy Markdown
Member Author

Will you revert your downgrades for PHP 8.3 as we will upgrade anyway or is this planned for a later PR?

I think we'll just upgrade that with symfony 8.0

@blued-gear
Copy link
Copy Markdown
Collaborator

I compared this PR with #1873 and listed some changes you can consider adding here

As I don't want to compare all files again, please let me know once you applied the suggestions (or rejected them with a short reason summary). I think then this PR can be approved.

@BentiGorlich
Copy link
Copy Markdown
Member Author

  • I removed all injected entity managers from the repositories
  • The things you said needed a migration did not come up when I ran the diff command
  • I will apply your method to force doctrine to reconnect to the sql server. I did miss that

@BentiGorlich BentiGorlich force-pushed the new/doctrine-upgrade branch from 9bbc57a to 2aac429 Compare March 13, 2026 10:21
@blued-gear
Copy link
Copy Markdown
Collaborator

I ran the branch a bit locally and it seems to work fine.

Still, I found 2 deprecations reported which are fixable. I created a branch with the suggested changes: https://github.com/MbinOrg/mbin/tree/new/doctrine-upgrade-gear_suggestions
Have a look at them and cherrypick what you find useful. The second commit might require PHP 8.4 .

We also have to think about a date when we are going upgrade PHP, Symfony and the Doctrine Pack to the latest major versions.

@BentiGorlich
Copy link
Copy Markdown
Member Author

I cherry picked your first commit. I think enabling enable_native_lazy_objects, even if it does not throw any exception will just not work until we move to php8.4

I am fine with bumping symfony to the new major version and with that also bumping php to 8.4. I just didn't want to do it here, since it was just not necessary, yet.

@BentiGorlich BentiGorlich merged commit 659f376 into main Mar 18, 2026
9 checks passed
@BentiGorlich BentiGorlich deleted the new/doctrine-upgrade branch March 18, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants