- Issue created by @hctom
- 🇩🇪Germany hctom
UPDATE: This only seems to happen, when
drupal/storybook
is enabled as well - I added it to the steps to reproduce. - 🇩🇪Germany hctom
I digged through the code a little more to track down this issue and I think I got it: the
getInfo()
implementation defines its callbacks like this:'#process' => [[$this, 'populateOptions']], '#element_validate' => [[$this, 'validateExistingComponent']], '#submit' => [[$this, 'submitForm']],
Using
$this
here results in the element class itself (and all its injected dependencies) being added to the element info array, which at last gets serialized before being written to cache.Tomorrow, I'll create an issue fork that contains the necessary changes to rewrite all those callbacks to
static
- which is also how core does it in all its form element plugins. - Status changed to Needs review
9 months ago 10:38am 22 March 2024 - 🇩🇪Germany hctom
Please see the issue fork for the fix. While fixing this issue, I also realized, that there was a
submitForm
callback registered, which is not defined in theComponenSelectorElement
, so I removed that one completely from the element information.And I think I even found the cause, why this issue only happens when
cl_editorial
andstorybook
module are both installed: Thestorybook
module provides a customDrupal\storybook\Cache\SkippableBackend
cache backend when development mode is enabled for that module - and this seems to result in the serialization error... but I am still confused, why this happens when re-installing a site from config, but maybe someone else has an idea, if maybe something has to be fixed at thestorybook
module as well?! - 🇩🇪Germany hctom
Any news on this? Because this prevents a site from being installed with both the
cl_editorial
andstorybook
module initially enabled. - e0ipso Can Picafort
I wonder if we could solve this by just adding
use DependencySerializationTrait;
to the class. Any chance you can try that? - 🇩🇪Germany hctom
That was the first thing I tried, when identifying the issue with the form element, but it does not fix the error, because the container itself still gets serialized due to
$this
usage in thegetInfo()
implementation (because all its information gets serialized when written to cache).As I already mentioned: ALL core elements use the
static
approach instead of using$this
, so this should be done with this element as well - and of course to avoid these errors ;)