Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
EntityDisplayBase::__sleep() serializes to toArray()
EntityDisplayBase::__wakeup() re-runs a toArray() to filter out
- Not sure why that is really needed
- That was written back when toArray() was a straightforward, simple operation. It is much more costly now that it leverages config schema.
We should check whether we can remove that toArray() call in EntityDisplayBase::__wakeup().
Comment | File | Size | Author |
---|---|---|---|
#3 | 2413841-EntityDisplayBase_wakeup-3.patch | 1.64 KB | yched |
#1 | 2413841-EntityDisplayBase_wakeup-1.patch | 654 bytes | yched |
Comments
Comment #1
yched CreditAttribution: yched commentedLet's see what breaks.
Comment #3
yched CreditAttribution: yched commentedOK, yeah, we cannot pass the whole set of $this properties into the __construct(), because that would cause $this->pluginManager to stay to its default value of NULL.
We really need to pass only the values from toArray() into the __construct(), but we need to know which those are without running toArray() again.
This should do the trick.
Ugly because of the way __sleep() / __wakeup() works, we should really try get back to Serializable :-/
Also, #2405165: Entity::setOriginalId() does enforceIsNew(FALSE), that is wrong for ConfigEntities would help making __wakeup() a bit clearer by removing the isNew() / enforceIsNew() dance.
Comment #4
amateescu CreditAttribution: amateescu commentedIndeed, the new code is quite ugly but since we don't have any better way to do it now, I think the performance of not involving the schema in these operations is worth it.
As far as I remember, the problem was some difference between 5.3 and 5.4, but now that we require PHP 5.4, I think it should be possible?
Comment #5
catchOK it is indeed not pretty, but I don't have a better idea and it's self-contained until we can sort out Serializable. Committed/pushed to 8.0.x, thanks!