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

Add doctrine/orm 3 support #590

Merged
merged 10 commits into from
Jul 14, 2024
Merged

Conversation

franmomu
Copy link
Member

Subject

This PR tries to add support for doctrine/orm 3

I am targeting this branch, because these changes are BC.

Changelog

### Added
- Support for `doctrine/orm` 3

The CI should be modified to allow installing doctrine/orm 3

@franmomu franmomu added the minor label Nov 19, 2023
src/AuditReader.php Outdated Show resolved Hide resolved
@franmomu
Copy link
Member Author

We need doctrine/data-fixtures#452

@franmomu franmomu force-pushed the orm3_support branch 2 times, most recently from abd07bd to 9e00c2f Compare November 23, 2023 18:46
@franmomu franmomu closed this Nov 24, 2023
@franmomu franmomu reopened this Nov 24, 2023
@greg0ire
Copy link

greg0ire commented Nov 25, 2023

The next blocker seems to be doctrine-extensions/DoctrineExtensions#2708

@franmomu
Copy link
Member Author

The next blocker seems to be doctrine-extensions/DoctrineExtensions#2708

Yep, that would take a bit longer I think, I'll try to help with that

@VincentLanglet
Copy link
Member

Hi @franmomu, what about following the same strategy than https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/4.x/.github/workflows/test_orm_3.yaml ?

gedmo/doctrine-extensions is an optional dev dependency, it should be a blocker for the ORM 3 support.

@amacrobert-meq
Copy link

Is there anything I can do to help this PR along? This bundle is holding up an ORM upgrade on our end, so I'm happy to help if I can.

@VincentLanglet
Copy link
Member

Is there anything I can do to help this PR along? This bundle is holding up an ORM upgrade on our end, so I'm happy to help if I can.

Basically, we need green tests.

If you want you can recreate the same PR and add a github actions similar to https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/4.x/.github/workflows/test_orm_3.yaml

Instead of removing AuditBundle you remove the doctrineExtensions.

@franmomu
Copy link
Member Author

I found some time to try to work on this, I've tried to remove some deprecations (related to accessing new mapping objects as array), but there should be more.

Not sure if I can keep working on this in the following days, so if anyone wants to continue with this, feel free to do it.

@franmomu franmomu marked this pull request as ready for review June 24, 2024 18:32
@franmomu
Copy link
Member Author

I think this is ready to be reviewed, the SimpleThings\EntityAudit\Utils\ORMCompatibilityTrait tries to avoid deprecations triggered by ORM 3 accessing to mapping objects as array.

At first, I've used a getMappingValue method for almost everything, and then I've starting using specific methods (getMappingColumnNameValue, getMappingNameValue, etc) to be able to be more specific about types.

Comment on lines -253 to +266
if (
($assoc['type'] & ClassMetadata::TO_ONE) === 0
|| false === $assoc['isOwningSide']
|| !isset($assoc['joinColumnFieldNames'])
) {
if (!self::isToOneOwningSide($assoc)) {
continue;
}

foreach ($assoc['joinColumnFieldNames'] as $sourceCol) {
/** @var string $sourceCol */
foreach (self::getMappingValue($assoc, 'joinColumnFieldNames') as $sourceCol) {
Copy link
Member Author

@franmomu franmomu Jun 24, 2024

Choose a reason for hiding this comment

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

The joinColumnFieldNames is only available in ToOneOwningSideMapping

Comment on lines 192 to 193
* @throws ORMException
* @throws ORM2Exception
Copy link
Member

Choose a reason for hiding this comment

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

Doctrine\ORM\Exception\ORMException

already exist in doctrine/orm 2.

And since ORMException extends ORM2Exception exception, I assume the doctrine codebase was updated and already throw ORMException everywhere ; so I would say we can remove all the @throws ORM2Exception tag, wdyt @franmomu ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah didn't check that, changed, thanks

Comment on lines -427 to +438
if (
($assoc['type'] & ClassMetadata::TO_ONE) > 0
&& true === $assoc['isOwningSide']
&& isset($assoc['targetToSourceKeyColumns'])
) {
foreach ($assoc['targetToSourceKeyColumns'] as $sourceCol) {
if (self::isToOneOwningSide($assoc)) {
foreach (self::getTargetToSourceKeyColumns($assoc) as $sourceCol) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The targetToSourceKeyColumns field is only available in ToOneOwningSideMapping

@VincentLanglet
Copy link
Member

Do you want me to merge/release or should we wait ? @franmomu

@franmomu franmomu requested review from phansys and a team July 13, 2024 07:51
@franmomu
Copy link
Member Author

since I've change some things, it would be nice to have another approval, I've requested reviews 🤞

@phansys phansys merged commit b982189 into sonata-project:1.x Jul 14, 2024
23 checks passed
@phansys
Copy link
Member

phansys commented Jul 14, 2024

Thank you @franmomu!

@VincentLanglet
Copy link
Member

VincentLanglet commented Jul 14, 2024

Go for the release #628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants