diff -u b/includes/entity.inc b/includes/entity.inc --- b/includes/entity.inc +++ b/includes/entity.inc @@ -190,8 +190,7 @@ // Ensure integer revision ID is valid. if (!empty($revision_id)) { - $revision_ids = array($revision_id); - $this->cleanIds($revision_ids); + $revision_id = $this->cleanRevisionId($revision_id); } // Load any remaining entities from the database. This is the case if $ids @@ -254,13 +253,31 @@ $ids = array_map('intval', $ids); } } + } + + /** + * Ensures integer entity revision ID is 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 int $id + * The entity ID revision to verify. Non-integer ID are removed from this + * array if the entity type requires ID to be integer. + * + * @return int|bool + * The passed in ID if it is valid, FALSE otherwise. + */ + protected function cleanRevisionId($id) { + $entity_info = entity_get_info($this->entityType); if (isset($entity_info['revision table field types'])) { $id_type = $entity_info['revision table field types'][$this->idKey]; if ($id_type == 'serial' || $id_type == 'int') { - $ids = array_filter($ids, array($this, 'filterId')); - $ids = array_map('intval', $ids); + return $this->filterId($id) ? $id : FALSE; } } + return $id; } /** @@ -300,6 +317,11 @@ $query->addTag($this->entityType . '_load_multiple'); + // Ensure integer revision ID is valid. + if (!empty($revision_id)) { + $revision_id = $this->cleanRevisionId($revision_id); + } + if ($revision_id) { $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id)); }