You are here

protected function DrupalDefaultEntityController::cleanIds in Drupal 7

Ensures integer entity IDs 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.

Parameters

array $ids: The entity IDs to verify. Non-integer IDs are removed from this array if the entity type requires IDs to be integers.

1 call to DrupalDefaultEntityController::cleanIds()
DrupalDefaultEntityController::load in includes/entity.inc
Implements DrupalEntityControllerInterface::load().

File

includes/entity.inc, line 242

Class

DrupalDefaultEntityController
Default implementation of DrupalEntityControllerInterface.

Code

protected function cleanIds(&$ids) {
  $entity_info = entity_get_info($this->entityType);
  if (isset($entity_info['base table field types'])) {
    $id_type = $entity_info['base table field types'][$this->idKey];
    if ($id_type == 'serial' || $id_type == 'int') {
      $ids = array_filter($ids, array(
        $this,
        'filterId',
      ));
      $ids = array_map('intval', $ids);
    }
  }
}