This might be a minor thing, and I might be missing something, but:
$storage->check() has the following line

$this->destroyUnrequiredInstances($container_ids);

Which again does this

 public function destroyUnrequiredInstances(array $container_ids) {

    // Find any instances of the storage's file that are in containers the
    // storage is not supposed to be in.
    $query = db_select('storage_instance', NULL, array('fetch' => PDO::FETCH_ASSOC));
    $query->join('storage_container', NULL, 'storage_instance.container_id = storage_container.container_id');

    $query->fields('storage_container')
      ->fields('storage_instance', array('reference'))
      ->condition('storage_instance.file_id', $this->file_id)
      ->orderBy('storage_container.container_id');

    if (count($container_ids)) {
      $query->condition('storage_instance.container_id', $container_ids, 'NOT IN');
    }

    $failure = FALSE;

    foreach ($query->execute() as $row) {
      $reference = $row['reference'];
      $container = storage_container_new($row);

Notice

      ->condition('storage_instance.file_id', $this->file_id)

If file_id is NULL, the query will give us all other storage_instances with NULL file-id's, which seems wrong.

We have quite a lot of storage_instances with NULL file_id's (I've been uable to figure out why, possible files queued for deletion), the result is the cron-hook taking (almost) forever.

Would something like this be ok?

    if (isset($this->file_id)) {
      $this->destroyUnrequiredInstances($container_ids);
    }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danquah’s picture

Perignon’s picture

Thanks! See if I can get this into dev today.

Perignon’s picture

Assigned: Unassigned » Perignon

  • Perignon committed 9d20be1 on 7.x-1.x authored by danquah
    Issue #2471639 by danquah: Missing check for file_id == null in before "...
Perignon’s picture

Status: Active » Fixed

Easy patch. In dev. Thanks for the contribution.

danquah’s picture

Great, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.