Skip to content

Fix invalid offset access on relationship without inversedBy and mappedBy #561

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

Conversation

alexandre-daubois
Copy link

When dealing with unilateral one-to-one relation like this:

class User
{
    #[OneToOne]
    public Address $adress
}

We have this error popping:

In AssociationMapping.php line 243:

   [OutOfRangeException]
   Unknown property "mappedBy" on class Doctrine\ORM\Mapping\OneToOneOwningSideMapping


 Exception trace:
   at /private/var/www/backoffice-api/vendor/doctrine/orm/src/Mapping/AssociationMapping.php:243
  Doctrine\ORM\Mapping\AssociationMapping->offsetGet() at
 /private/var/www/backoffice-api/vendor/zenstruck/foundry/src/Factory.php:463
  Zenstruck\Foundry\Factory::getRelationshipMetadata() at
 /private/var/www/backoffice-api/vendor/zenstruck/foundry/src/Factory.php:411
  Zenstruck\Foundry\Factory->normalizeAttribute() at
 /private/var/www/backoffice-api/vendor/zenstruck/foundry/src/Factory.php:111
  Zenstruck\Foundry\Factory->create() at
 /private/var/www/backoffice-api/src/DataFixtures/Story/User/UserStory.php:29
  App\DataFixtures\Story\Kitchen\KitchenBlockStory->build() at
 /private/var/www/backoffice-api/vendor/zenstruck/foundry/src/StoryManager.php:52

It happened when trying to upgrade to DBAL4/ORM3. I think this fix can help support latest Doctrine's versions 🙂

@nikophil
Copy link
Member

nikophil commented Feb 14, 2024

Hi @alexandre-daubois

thanks for this!

the failures you have here are unrelated to your fix. I'm gonna fix this very soon.

We need to work on ORM 3/DBAL 4 compatiblity with Foundry, I'd be curious to have you feedback about it.

when looking at this PR and the related failures in the CI, I'd say there should not be too much work (and we can see that the CI hit your error)

@alexandre-daubois
Copy link
Author

Alright, thank you for having a look! Feel free to ping me to try the "real" fix for this problem, I'd be happy to help and give feedback 😊

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

Successfully merging this pull request may close these issues.

2 participants