PayumBundle icon indicating copy to clipboard operation
PayumBundle copied to clipboard

utf8mb4_unicode_ci (mysql)

Open jayesbe opened this issue 9 years ago • 12 comments

I am need of setting a length on the hash column in the Token entity.

In the Payum Core under Core/Bridge/Doctrine/Resources/mapping/Token.orm.xml

I need to add a length=191 on to the hash column. Whats the easiest way to override ?

I tried to extend the PayumBundle with MyOwnPayumBundle. I then tried to override the DI Extension class PayumExtension. Except that it wasn't finding the configuration tree. It seems I then need to override several other classes. Is there a better alternative ?

jayesbe avatar Dec 25 '15 20:12 jayesbe

No need for the whole bundle. You have to add a listener and listen to load class metadata event.There you will be able to adjust the field parameters.

makasim avatar Jan 14 '16 17:01 makasim

Actually I only had to use @attributeOverride :)

jayesbe avatar Jan 17 '16 12:01 jayesbe

@attributeOverride is definitely the way to go but it will affect Doctrine's generate entity command, I think this really should be handled in this bundle's model class and as such this issue should be re-opened for further discussion.

The-Don-Himself avatar Feb 09 '17 02:02 The-Don-Himself

You can always create your own model that implements interface and define fields mapping as you'd like.

makasim avatar Feb 09 '17 09:02 makasim

Wow old ticket, in any case.. @attributeOverride worked perfect.. I would expect doctrine's generate entity command to be affected. I've had to do this with other bundles as well and has worked without exception for the moment.

jayesbe avatar Feb 09 '17 10:02 jayesbe

@jayesbe Indeed @attributeOverride works, I have also encountered this issue in FOSOauthServerBundle as well and the override works there as well.

I think the issue is that these are only temporary solutions in my view and should be catered for in the bundle like FOSUserBundle did after many people ran into it.

https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1919

Symfony docs have recommended utf8mb4 for about a year and a half now, this issue makes PayumBundle incompatible out of the box without @Override.

@makasim maybe if you don't want to change the length would you consider a mention in the docs? I can make a PR for either if you want.

The-Don-Himself avatar Feb 09 '17 12:02 The-Don-Himself

We are facing the same Issue but somehow @AttributeOverride does not work, we tried it on two different systems where we first deleted the cache folder completely.

@The-Don-Himself are you still willing to submit a PR for this Issue?

kirtixs avatar May 11 '17 15:05 kirtixs

You can always create your own model that implements the interface and define fields mapping as you'd like.

This is still the valid case. There is no need to use models from the bundle you can create your own with required doctrine settings.

makasim avatar May 11 '17 15:05 makasim

Okay, we'll do that, but it's still weird that the default setup is broken.

kirtixs avatar May 11 '17 19:05 kirtixs

@redshark1802 I am willing to submit a PR for this because the changes required are really simple, maybe 15secs only but project owner @makasim has opted the community follow a different route which is his prerogative anyway and to be honest is equally simple with the bonus of learning a little bit more about Doctrine entities.

If your still having an issue, paste your entities and error and we'll help. For you're specific issue,my suspicion is that you have configured doctrine to cache metadata either in redis or apc hence deleting the cache folder wont help but either clearing redis from cli (nuclear option) of restarting apache (another nuclear option) but thae best is to run this command

php bin/console doctrine:cache:clear-metadata --env=prod

or

php bin/console doctrine:cache:clear-metadata --env=dev

The-Don-Himself avatar May 12 '17 01:05 The-Don-Himself

@The-Don-Himself Don't get me wrong. I do not against the change and I see reasons behind it. The problem is such a change is a huge BC break and we simply cannot do it without bumping the major version.

We could think of other solutions, for example, we can add a new base model with a new metadata class for it.

makasim avatar May 12 '17 06:05 makasim

@makasim yes you're right, I keep forgetting that some changes, no matter how small will cause BC breaks. Perhaps just add it to the 3.x timeline and anyone who needs help can always follow this thread.

The-Don-Himself avatar May 12 '17 23:05 The-Don-Himself