Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude __rawRelationData from being serialized + getBlockedVars() timizations #16596

Merged
merged 2 commits into from May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/Asset.php
Expand Up @@ -168,7 +168,7 @@ public function setDataModificationDate(?int $dataModificationDate): static

protected function getBlockedVars(): array
{
$blockedVars = ['scheduledTasks', 'versions', 'parent', 'stream'];
$blockedVars = ['scheduledTasks', 'versions', 'stream'];
kingjia90 marked this conversation as resolved.
Show resolved Hide resolved

if (!$this->isInDumpState()) {
// for caching asset
Expand Down
4 changes: 2 additions & 2 deletions models/DataObject/AbstractObject.php
Expand Up @@ -117,14 +117,14 @@ abstract class AbstractObject extends Model\Element\AbstractElement

protected function getBlockedVars(): array
{
$blockedVars = ['versions', 'class', 'scheduledTasks', 'parent', 'parent', 'omitMandatoryCheck'];
$blockedVars = ['versions', 'class', 'scheduledTasks', 'omitMandatoryCheck'];

if ($this->isInDumpState()) {
// this is if we want to make a full dump of the object (eg. for a new version), including children for recyclebin
$blockedVars = array_merge($blockedVars, ['dirtyFields']);
} else {
// this is if we want to cache the object
$blockedVars = array_merge($blockedVars, ['children', 'properties', 'properties']);
$blockedVars = array_merge($blockedVars, ['children', 'properties']);
}

return $blockedVars;
Expand Down
7 changes: 3 additions & 4 deletions models/DataObject/Concrete.php
Expand Up @@ -29,6 +29,7 @@
use Pimcore\Model\DataObject\Exception\InheritanceParentNotFoundException;
use Pimcore\Model\Element\DirtyIndicatorInterface;
use Pimcore\SystemSettingsConfig;
use function array_merge;

/**
* @method \Pimcore\Model\DataObject\Concrete\Dao getDao()
Expand Down Expand Up @@ -710,13 +711,11 @@ public function markAllLazyLoadedKeysAsLoaded(): void
public function __sleep(): array
{
$parentVars = parent::__sleep();

$finalVars = [];

$blockedVars = [];
$blockedVars = ['__rawRelationData'];

if (!$this->isInDumpState()) {
$blockedVars = ['loadedLazyKeys', 'allLazyKeysMarkedAsLoaded'];
$blockedVars = array_merge(['loadedLazyKeys', 'allLazyKeysMarkedAsLoaded'], $blockedVars);
// do not dump lazy loaded fields for caching
$lazyLoadedFields = $this->getLazyLoadedFieldNames();
$blockedVars = array_merge($lazyLoadedFields, $blockedVars);
Expand Down
2 changes: 1 addition & 1 deletion models/Document.php
Expand Up @@ -89,7 +89,7 @@ class Document extends Element\AbstractElement

protected function getBlockedVars(): array
{
$blockedVars = ['versions', 'scheduledTasks', 'parent', 'fullPathCache'];
$blockedVars = ['versions', 'scheduledTasks', 'fullPathCache'];

if (!$this->isInDumpState()) {
// this is if we want to cache the object
Expand Down
2 changes: 1 addition & 1 deletion models/Element/AbstractElement.php
Expand Up @@ -634,7 +634,7 @@ public function __sleep(): array
$this->removeInheritedProperties();
}

return array_diff(parent::__sleep(), $this->getBlockedVars());
return array_diff(parent::__sleep(), $this->getBlockedVars(), self::getBlockedVars());
}

public function __wakeup(): void
Expand Down