-
Notifications
You must be signed in to change notification settings - Fork 0
Bug Report: msgphp/user: respect mysql/mariadb max length for indexes/unique #210
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
Comments
Hi @pascalwacker , I think it's a recall for #159 :) however, im still not sure how to tackle this from a vendor perspective. The attributeOverride option looks the cleanest to me =/ I'll try to give it some more thought. |
@ro0NL so I tried to add an override, unfortunately it told me, there's no attribute Error: The used override:
|
i never really tested it :) The field is derived from an credential embeddable (User::$credential), so perhaps try Otherwise, and worst case, you'll need to override the Credential class and override it's own field from there on. Or, we do something clever in core, but i'm not sure yet. In theory we should be able to generate specific mapping files, as those are copied from dist files. |
Unfortunately About overriding the Credential class: Am I guessing right, that I would have to override |
It seams to be the case, that embedded properties can't be overridden yet: doctrine/orm#6047 but then on the other hand, the doctrine doc says it should work: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/tutorials/override-field-association-mappings-in-subclasses.html#override-field-association-mappings-in-subclasses |
You can copy https://github.com/msgphp/msgphp/blob/master/src/User/Entity/Credential/EmailPassword.php and add the ORM annotations as needed. Next, copy the trait for your User entiy: https://github.com/msgphp/msgphp/blob/master/src/User/Entity/Features/EmailPasswordCredential.php where you wire your custom credential. Last, update your User constructor to initialize your custom credential instead. That's the theory. Actually documenting this is still on my lists. So if it works out, please share. But ideally i like to handle this in core somehow. |
For the reset password feature, copy https://github.com/msgphp/msgphp/blob/master/src/User/Entity/Features/ResettablePassword.php and explicitly enable its domain event: msgphp_user:
commands:
MsgPhp\User\Command\RequestUserPasswordCommand: true But i agree, this is a lot of work only to override a ORM mapping :( |
What about the file in If I could just override the |
they are copied as-is to the cache folder, so not really. But i think this is actually a nice way to customize: being able to own/modify the mapping files. Something like msgphp_user:
doctrine:
mapping: { dir: 'some/path/', type: xml } Anything not defined there will be inherited from the core dist files. |
How about copying them to Btw. I tried to use a service decorator,
To override the Extension class, and was planing on forwarding all the calls to the original one, except for the |
Extension class is a corner stone of the bundle, and not meant to be used as a service. You can't go down that road. For now your best hook-in point is https://github.com/msgphp/msgphp/blob/master/src/Domain/Infra/Doctrine/MappingCacheWarmer.php which is registered as a service and copies the mapping files to the cache folder. The reason we do this, is some mapping files are optional (e.g. But i like the idea to detect overrides in |
So what I ended up doing was decorating the
I then copied the file in
|
👏 so let's simplify from here on, if the overridden files end up in the core cache warmer we should be good. Does the proposed config work for you? In your case it be: msgphp_user:
doctrine:
mapping: '%kernel.project_dir%/config/packages/msgphp/user' That can be used from here on:
|
Seams there's still one problem, which the pull doesn't solve (yet). The |
@pascalwacker for now i think you can redeclare the trait properties in your class, e.g.
and add the annotation while doing so. That should override the default mapping here. We might need another feature to override the built-in trait/object mappings more globally :P |
Actually you can create your own |
Currently there are 3 open pull requests, aiming at solving this issue
My suggestion would be to use pull 214 and 211. Since both modify the `CacheWarmer, they can't simply be merged. If you agree on this path, I would modify pull 214 to incorporate the changes from 211, this way we would get a nice config parameter for key lengths that's respected by every thing, as well as the ability to override selected config files, while keeping the default ones. Let me know what you think. |
@pascalwacker i like to continue with #214 #211 indeed 👍 From #214 if we have a |
Bug Report: I've just tried to install the user bundle: https://github.com/msgphp/user which went well until I tried to run the db migrations.
Steps to reproduce, take a Symfony 4.1 web skeleton, run
composer require annot form validator twig security messenger orm
,composer require maker --dev
,composer require msgphp/user-bundle
andbin/console make:user:msgphp
I've answered all questions with the default value and approved all writes. After that I ran
bin/console make:migration
andbin/console doctrine:migrations:migrate
The code generated by
bin/console make:migration
looked like this:When I ran the migration file using
bin/console doctrine:migrations:migrate
I got an error, telling me, that primary key and unique column where to long:I "fixed" (more a temporary hack ;)) it by adding a
length=25
inside the@ORM\Column()
statement for the name in\App\Entity\User\Role
and changed the migration file to only have 90 characters forcredential_email
andpassword_reset_token
in the user table.It would be great if either the bundle could respect mysql/mariadb max index size or to have a hint in the bundles README.md file (and also how to restrict the character amount of the fields).
The text was updated successfully, but these errors were encountered: