diff --git a/includes/file.inc b/includes/file.inc index 1278d39d4799704700a84842c573c1b06e2e5d96..bc8ae79d325d54108ecd638521b4e20b67c6d408 100644 --- a/includes/file.inc +++ b/includes/file.inc @@ -605,7 +605,8 @@ function file_save(stdClass $file) { * * @return * A nested array with usage data. The first level is keyed by module name, - * the second by object type, the third has 'id' and 'count' keys. + * the second by object type and the third by the object id. The value + * of the third level contains the usage count. * * @see file_usage_add() * @see file_usage_delete() @@ -618,7 +619,7 @@ function file_usage_list(stdClass $file) { ->execute(); $references = array(); foreach ($result as $usage) { - $references[$usage->module][$usage->type] = array('id' => $usage->id, 'count' => $usage->count); + $references[$usage->module][$usage->type][$usage->id] = $usage->count; } return $references; } diff --git a/modules/simpletest/tests/file.test b/modules/simpletest/tests/file.test index 9dbe5464fc1e8b754daeabe24fbcaa8cdb46f344..db4097c44a0b38d5124f38540fcf294a9404cb94 100644 --- a/modules/simpletest/tests/file.test +++ b/modules/simpletest/tests/file.test @@ -1563,7 +1563,7 @@ class FileDeleteTest extends FileHookTestCase { file_usage_delete($file, 'testing', 'test', 1); file_delete($file); $usage = file_usage_list($file); - $this->assertEqual($usage['testing']['test'], array('id' => 1, 'count' => 1), t('Test file is still in use.')); + $this->assertEqual($usage['testing']['test'], array(1 => 1), t('Test file is still in use.')); $this->assertTrue(file_exists($file->uri), t('File still exists on the disk.')); $this->assertTrue(file_load($file->fid), t('File still exists in the database.')); @@ -2066,10 +2066,10 @@ class FileUsageTest extends FileTestCase { $usage = file_usage_list($file); $this->assertEqual(count($usage['testing']), 2, t('Returned the correct number of items.')); - $this->assertEqual($usage['testing']['foo']['id'], 1, t('Returned the correct id.')); - $this->assertEqual($usage['testing']['bar']['id'], 2, t('Returned the correct id.')); - $this->assertEqual($usage['testing']['foo']['count'], 1, t('Returned the correct count.')); - $this->assertEqual($usage['testing']['bar']['count'], 2, t('Returned the correct count.')); + $this->assertTrue(isset($usage['testing']['foo'][1]), t('Returned the correct id.')); + $this->assertTrue(isset($usage['testing']['bar'][2]), t('Returned the correct id.')); + $this->assertEqual($usage['testing']['foo'][1], 1, t('Returned the correct count.')); + $this->assertEqual($usage['testing']['bar'][2], 2, t('Returned the correct count.')); } /**