Skip to content
Snippets Groups Projects
Commit 54a49d50 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2313053 by Berdir: Fixed Field storage and instance call toArray() in...

Issue #2313053 by Berdir: Fixed Field storage and instance call toArray() in __wakeup() is very slow, remove it?.
parent e6657946
No related branches found
No related tags found
No related merge requests found
......@@ -617,7 +617,7 @@ public function targetBundle() {
return $this->bundle;
}
/*
/**
* Implements the magic __sleep() method.
*
* Using the Serialize interface and serialize() / unserialize() methods
......@@ -625,20 +625,11 @@ public function targetBundle() {
* @todo Investigate in https://drupal.org/node/2074253.
*/
public function __sleep() {
// Only serialize properties from self::toArray().
$properties = array_keys(array_intersect_key($this->toArray(), get_object_vars($this)));
// Serialize $entityTypeId property so that toArray() works when waking up.
$properties[] = 'entityTypeId';
return $properties;
}
/**
* Implements the magic __wakeup() method.
*/
public function __wakeup() {
// Run the values from self::toArray() through __construct().
$values = array_intersect_key($this->toArray(), get_object_vars($this));
$this->__construct($values);
// Only serialize necessary properties, excluding those that can be
// recalculated.
$properties = get_object_vars($this);
unset($properties['fieldStorage'], $properties['itemDefinition'], $properties['bundle_rename_allowed']);
return array_keys($properties);
}
/**
......
......@@ -642,20 +642,11 @@ public function hasData() {
* @todo Investigate in https://drupal.org/node/2074253.
*/
public function __sleep() {
// Only serialize properties from self::toArray().
$properties = array_keys(array_intersect_key($this->toArray(), get_object_vars($this)));
// Serialize $entityTypeId property so that toArray() works when waking up.
$properties[] = 'entityTypeId';
return $properties;
}
/**
* Implements the magic __wakeup() method.
*/
public function __wakeup() {
// Run the values from self::toArray() through __construct().
$values = array_intersect_key($this->toArray(), get_object_vars($this));
$this->__construct($values);
// Only serialize necessary properties, excluding those that can be
// recalculated.
$properties = get_object_vars($this);
unset($properties['schema'], $properties['propertyDefinitions']);
return array_keys($properties);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment