dereuromark / cakephp-queue

Queue plugin for CakePHP - simple, pure PHP and without dependencies.
MIT License
307 stars 136 forks source link

Change serializer to custom database column type #398

Closed michielkeijts closed 6 months ago

michielkeijts commented 7 months ago

Just wondering why there still is a specific serializer class and not a 'column type' serializer, like CakePHP suggests: link

It means that right now with every save of a job, you need to make the the data is serialized in your own function, compared to the option above, that a JsonType (or othere type) database column deals with this automatically.

There must be a good reason for the current serialization, but I was wondering if something like the database column type serlalizer could be a nice feature (I'm up for this)

dereuromark commented 7 months ago

Well, it would make sense if the whole column would be serialized the same way (JSON) and the type would be supported across the systems. Legacy wise it used to be not this case, e.g. could be PHP native serialized (objects!), or the DB types didnt have a consistent way of doing it for all DBs

Now with JSON I agree, we could go that way. Maybe that way we dont even need the config anymore for serialize type. See https://github.com/dereuromark/cakephp-queue/issues/394

Feel free to make a PR and maybe we can make a major here that cleans this up once and for all

dereuromark commented 7 months ago

Also note that we will have to check that it supports https://github.com/dereuromark/cakephp-queue/pull/397

Also, it will directly conflict with https://github.com/dereuromark/cakephp-queue/issues/396 and any PHP serialization of objects as a whole.

Not a bad thing from my perspective as those are always easy to break with updates anyway But for some those might be important use cases for some queues, so we need to see how we work around that. Maybe a serialized string that then gets json encoded :) If that works.

michielkeijts commented 7 months ago

I agree, it should be BC and not brake anything at this moment, but for future development usages, it's best to prevent to be dependend on a serialized php object or so. And mention this explicitly

And maybe the json encoded version of a serialized object (or such) can be a good option. But, we can also say that, instead of using the current serializers, a database serializer is used. We rewrite the current serializers to be this database-field serializers and people can still use a custom serializer, but then build their own based on adding custom type (link)

michielkeijts commented 7 months ago

I will create a PR in the coming week or so

dereuromark commented 7 months ago

@michielkeijts Still interested in trying this out?

dereuromark commented 6 months ago

ping @michielkeijts

michielkeijts commented 6 months ago

ping @michielkeijts

still interested, but was afk for a week. thanks for putting something together