diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index d9a60ec..204351e 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -606,22 +606,24 @@ protected function populateAffectedRevisionTranslations(ContentEntityInterface $ } /** - * Ensures integer entity IDs are valid. + * Ensures integer entity key values are valid. * * The identifier sanitization provided by this method has been introduced * as Drupal used to rely on the database to facilitate this, which worked * correctly with MySQL but led to errors with other DBMS such as PostgreSQL. * * @param array $ids - * The entity IDs to verify. + * The entity key values to verify. + * @param array $key + * (optional) The entity key to sanitise values for. Defaults to 'id'. * * @return array - * The sanitized list of entity IDs. + * The sanitized list of entity key values. */ - protected function cleanIds(array $ids) { + protected function cleanIds(array $ids, $key = 'id') { $definitions = $this->entityManager->getBaseFieldDefinitions($this->entityTypeId); - $id_definition = $definitions[$this->entityType->getKey('id')]; - if ($id_definition->getType() == 'integer') { + $field_name = $this->entityType->getKey($key); + if ($field_name && $definitions[$field_name]->getType() == 'integer') { $ids = array_filter($ids, function ($id) { return is_numeric($id) && $id == (int) $id; }); diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 9e0d34f..064a780 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -467,7 +467,7 @@ protected function doLoadMutlipleRevisions(array $revision_ids) { if (!empty($revision_ids)) { // Sanitize IDs. Before feeding ID array into buildQuery, check whether // it is empty as this would load all entities. - $revision_ids = $this->cleanIds($revision_ids); + $revision_ids = $this->cleanIds($revision_ids, 'revision'); } if ($revision_ids === NULL || $revision_ids) {