Commit f66ac343 authored by catch's avatar catch

Issue #1292374 by jbrown, chris.leversuch, slashrsm, karschsp, Kevin Morse,...

Issue #1292374 by jbrown, chris.leversuch, slashrsm, karschsp, Kevin Morse, Berdir: Fixed Enable static caching for File entities.
parent 20fe13eb
......@@ -104,6 +104,8 @@ function file_entity_view_mode_info() {
*
* @param array $fids
* (optional) An array of entity IDs. If omitted, all entities are loaded.
* @param $reset
* Whether to reset the internal file_load_multiple() cache.
*
* @return array
* An array of file entities, indexed by fid.
......@@ -113,8 +115,8 @@ function file_entity_view_mode_info() {
* @see entity_load()
* @see Drupal\Core\Entity\Query\EntityQueryInterface
*/
function file_load_multiple(array $fids = NULL) {
return entity_load_multiple('file', $fids);
function file_load_multiple(array $fids = NULL, $reset = FALSE) {
return entity_load_multiple('file', $fids, $reset);
}
/**
......@@ -122,6 +124,8 @@ function file_load_multiple(array $fids = NULL) {
*
* @param $fid
* A file ID.
* @param $reset
* Whether to reset the internal file_load_multiple() cache.
*
* @return Drupal\file\File
* A file entity or FALSE if the file was not found.
......@@ -129,8 +133,8 @@ function file_load_multiple(array $fids = NULL) {
* @see hook_file_load()
* @see file_load_multiple()
*/
function file_load($fid) {
$files = file_load_multiple(array($fid));
function file_load($fid, $reset = FALSE) {
$files = file_load_multiple(array($fid), $reset);
return reset($files);
}
......
......@@ -21,7 +21,6 @@
* module = "file",
* controller_class = "Drupal\file\FileStorageController",
* base_table = "file_managed",
* static_cache = FALSE,
* entity_keys = {
* "id" = "fid",
* "label" = "filename",
......
......@@ -71,7 +71,7 @@ function testInUse() {
drupal_cron_run();
// system_cron() loads
$this->assertFileHooksCalled(array('load', 'delete'));
$this->assertFileHooksCalled(array('delete'));
$this->assertFalse(file_exists($file->uri), t('File has been deleted after its last usage was removed.'));
$this->assertFalse(file_load($file->fid), t('File was removed from the database.'));
}
......
......@@ -82,7 +82,7 @@ function testMultiple() {
// Load by fid.
file_test_reset();
$by_fid_files = file_load_multiple(array($file->fid));
$this->assertFileHookCalled('load');
$this->assertFileHooksCalled(array());
$this->assertEqual(1, count($by_fid_files), t('file_load_multiple() returned an array of the correct size.'));
$by_fid_file = reset($by_fid_files);
$this->assertTrue($by_fid_file->file_test['loaded'], t('file_test_file_load() was able to modify the file during load.'));
......
......@@ -78,7 +78,7 @@ function testCreateDeletePicture() {
drupal_cron_run();
// Verify that the image has been deleted.
$this->assertFalse(file_load($file->fid), 'File was removed from the database.');
$this->assertFalse(file_load($file->fid, TRUE), 'File was removed from the database.');
// Clear out PHP's file stat cache so we see the current value.
clearstatcache(TRUE, $file->uri);
$this->assertFalse(is_file($file->uri), 'File was removed from the file system.');
......@@ -122,6 +122,6 @@ function saveUserPicture($image) {
// Load actual user data from database.
$account = user_load($this->web_user->uid, TRUE);
return file_load($account->user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid']);
return file_load($account->user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid'], TRUE);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment