diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 8648a42..d42a3d2 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -247,9 +247,9 @@ public function getInstance(array $options) { * @see \Drupal\Core\TypedData\TypedDataManager::create() */ public function getPropertyInstance(TypedDataInterface $object, $property_name, $value = NULL) { - // For performance, try to reuse existing prototypes instead of constructing - // new objects when possible. A prototype is reused when creating a data - // object: + // For performance, try to reuse existing prototypes instead of + // constructing new objects when possible. A prototype is reused when + // creating a data object: // - for a similar root object (same data type and settings), // - at the same property path under that root object. $root_definition = $object->getRoot()->getDataDefinition(); @@ -262,6 +262,8 @@ public function getPropertyInstance(TypedDataInterface $object, $property_name, // Root data type and settings. $parts[] = $root_definition->getDataType(); if ($settings = $root_definition->getSettings()) { + // Hash the settings into a string. crc32 is the the fastest way to hash + // something for non-cryptographic purposes. $parts[] = crc32(serialize($settings)); } // Property path for the requested data object. When creating a list item, @@ -284,8 +286,8 @@ public function getPropertyInstance(TypedDataInterface $object, $property_name, if (!$definition) { throw new \InvalidArgumentException('Property ' . String::checkPlain($property_name) . ' is unknown.'); } - // Create the prototype with initial parenting information, but without - // any value. + // Create the prototype without any value, but with initial parenting + // so that constructors can set up the objects correclty. $this->prototypes[$key] = $this->create($definition, NULL, $property_name, $object); }