diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 0ead1bc..fed77e7 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -42,6 +42,13 @@ protected $bundle; /** + * Local cache holding the value of the ID key name from annotation. + * + * @var string + */ + protected $idKeyName = 'id'; + + /** * The plain data values of the contained fields. * * This always holds the original, unchanged values of the entity. The values @@ -353,7 +360,10 @@ public function __wakeup() { * {@inheritdoc} */ public function id() { - return $this->get($this->entityInfo()->getKey('id'))->value; + if (!isset($this->idKeyName)) { + $this->idKeyName = $this->entityInfo()->getKey('id'); + } + return $this->get($this->idKeyName)->value; } /**