- 🇺🇸United States dcam
Also, I don't think we need to postpone this on #3421234. We just need to use
PhpSerialize
. Then it can do whatever it's going to do and benefit from those improvements. - 🇺🇸United States dcam
I'm not done working on this, but I need to save my progress because I've been making these changes on my work laptop and I'm about to head home for the weekend.
I agree with the things @berdir said.
this probably shouldn't be public inside the storage, it's not a meant to be a public api?
Yeah, I don't think we should put utility methods in entity storage classes. That's the kind of thing services are for. And we already have a service for serialization. Let's use it.
I'm not sure if we should silently drop invalid values
No, we shouldn't. We should be doing whatever
PhpSerialize
does. The utility method picked up a few extra things that it did that are outside the scope of this issue. Dropping the invalid values were included. It also included converting empty strings to NULL. That's a behavior change that could impact downstream code and I don't even know what prompted it. I got rid of all of it. Now thesafeUnserialize()
function only checks the NULL case, then passes the work off toPhpSerialize
.testSafeUnserialize
has to be updated because I made that static utility function protected. Also,InitializeSerializedPropTest
passes with or without the bug fix. So something about that test is wrong. - 🇺🇸United States dcam
The Link field also has this problem with its serialized options column that can be NULL. See 🐛 Avoid error when $options is NULL in buildUrl() Needs work .
- 🇺🇸United States dww
Love this. But curious how it would work in the Field UI. Is the idea that if a field uses this to manage allowed values, that those parts of the UI where you define the values and labels would disappear or something?
- 🇦🇺Australia acbramley
In 📌 Introduce and make use of NodePreview enum, to replace node related usage of DRUPAL_DISABLED, DRUPAL_OPTIONAL and DRUPAL_REQUIRED constants Active I'm looking to add a trait that allows you to do this very easily (although not quite like what is being proposed in the current MR).
The OptionsEnumTrait adds
::asOptions
to an enum and forces alabel
method to be implemented. You can then useMyEnum::asOptions
in the FAPI#options
key, and also for things like field storage definitions with theallowed_values_function
key