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

[Doctrine Bridge] Doctrine Extractor throws an exception with index-by over custom mapping type #35542

Closed
mikemix opened this issue Jan 31, 2020 · 0 comments

Comments

@mikemix
Copy link

mikemix commented Jan 31, 2020

Symfony version(s) affected: 4.4.3

Description
I have custom Doctrine types, eg:

doctrine:
  dbal:
    types:
      users_user_id: Base\Infrastructure\Doctrine\Type\UsersUserId

After upgrading to 4.4.3 the DoctrineExtractor throws an exception:

Argument 1 passed to Symfony\Component\PropertyInfo\Type::__construct() must be of the type string, null given, called in /var/www/html/vendor/symfony/doctrine-bridge/PropertyInfo/DoctrineExtractor.php on line 126

This happens with index-by over custom mapping type, eg:

<many-to-many field="managers" target-entity="Base\Users\Domain\Model\User" index-by="id" />

Additional context

obraz

@mikemix mikemix changed the title [Doctrine Bridge] Doctrine Extractor throws exception on custom mapping type [Doctrine Bridge] Doctrine Extractor throws an exception with index-by over custom mapping type Jan 31, 2020
fabpot added a commit that referenced this issue Feb 21, 2020
…m and some core types (fancyweb)

This PR was merged into the 3.4 branch.

Discussion
----------

[DoctrineBridge][DoctrineExtractor] Fix indexBy with custom and some core types

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #35542 and #35604
| License       | MIT
| Doc PR        | -

For #35604:
To guess the collection key type, the `getPhpType()` method is called. But it does not handle most objects and arrays core types. This is why an indexBy datetime does not work.

For #35542:
When the php type cannot be guessed, null is returned. In this case, we cannot pass a valid builtin type to PropertyInfo Type, so we should return null.

Commits
-------

018ec1a [DoctrineBridge][DoctrineExtractor] Fix indexBy with custom and some core types
@fabpot fabpot closed this as completed Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants