Projet

Général

Profil

Révision db2d93dd

Ajouté par Benjamin Luce il y a presque 9 ans

Update to 7.37

Voir les différences:

drupal7/includes/entity.inc
183 183
      }
184 184
    }
185 185

  
186
    // Ensure integer entity IDs are valid.
187
    if (!empty($ids)) {
188
      $this->cleanIds($ids);
189
    }
190

  
186 191
    // Load any remaining entities from the database. This is the case if $ids
187 192
    // is set to FALSE (so we load all entities), if there are any ids left to
188 193
    // load, if loading a revision, or if $conditions was passed without $ids.
......
223 228
    return $entities;
224 229
  }
225 230

  
231
  /**
232
   * Ensures integer entity IDs are valid.
233
   *
234
   * The identifier sanitization provided by this method has been introduced
235
   * as Drupal used to rely on the database to facilitate this, which worked
236
   * correctly with MySQL but led to errors with other DBMS such as PostgreSQL.
237
   *
238
   * @param array $ids
239
   *   The entity IDs to verify. Non-integer IDs are removed from this array if
240
   *   the entity type requires IDs to be integers.
241
   */
242
  protected function cleanIds(&$ids) {
243
    $entity_info = entity_get_info($this->entityType);
244
    if (isset($entity_info['base table field types'])) {
245
      $id_type = $entity_info['base table field types'][$this->idKey];
246
      if ($id_type == 'serial' || $id_type == 'int') {
247
        $ids = array_filter($ids, array($this, 'filterId'));
248
        $ids = array_map('intval', $ids);
249
      }
250
    }
251
  }
252

  
253
  /**
254
   * Callback for array_filter that removes non-integer IDs.
255
   */
256
  protected function filterId($id) {
257
    return is_numeric($id) && $id == (int) $id;
258
  }
259

  
226 260
  /**
227 261
   * Builds the query to load the entity.
228 262
   *

Formats disponibles : Unified diff