Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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);
}
Comment | File | Size | Author |
---|---|---|---|
#1 | storage_api-check-for-null-file-id-2471639-1.patch | 455 bytes | danquah |
Comments
Comment #1
danquah CreditAttribution: danquah commentedComment #2
Perignon CreditAttribution: Perignon commentedThanks! See if I can get this into dev today.
Comment #3
Perignon CreditAttribution: Perignon commentedComment #5
Perignon CreditAttribution: Perignon commentedEasy patch. In dev. Thanks for the contribution.
Comment #6
danquah CreditAttribution: danquah commentedGreat, thanks!