summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2013-02-12 12:14:30 (GMT)
committercatch2013-02-12 12:14:30 (GMT)
commitf66ac34331452e07b76347ddada6bad335f715ad (patch)
tree7799bb512b31b85be377611aca3eb96e664c00eb
parent20fe13eb87f4093762171ae6b80599588050f7c6 (diff)
Issue #1292374 by jbrown, chris.leversuch, slashrsm, karschsp, Kevin Morse, Berdir: Fixed Enable static caching for File entities.
-rw-r--r--core/modules/file/file.module12
-rw-r--r--core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php1
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/DeleteTest.php2
-rw-r--r--core/modules/file/lib/Drupal/file/Tests/LoadTest.php2
-rw-r--r--core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php4
5 files changed, 12 insertions, 9 deletions
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 913f75a..75c4f84 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -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);
}
diff --git a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php
index d7f2a6b..e811c58 100644
--- a/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php
+++ b/core/modules/file/lib/Drupal/file/Plugin/Core/Entity/File.php
@@ -21,7 +21,6 @@ use Drupal\Core\Annotation\Translation;
* module = "file",
* controller_class = "Drupal\file\FileStorageController",
* base_table = "file_managed",
- * static_cache = FALSE,
* entity_keys = {
* "id" = "fid",
* "label" = "filename",
diff --git a/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php b/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php
index 6adafdb..ca2f712 100644
--- a/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/DeleteTest.php
@@ -71,7 +71,7 @@ class DeleteTest extends FileManagedTestBase {
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.'));
}
diff --git a/core/modules/file/lib/Drupal/file/Tests/LoadTest.php b/core/modules/file/lib/Drupal/file/Tests/LoadTest.php
index 833c260..aaaec27 100644
--- a/core/modules/file/lib/Drupal/file/Tests/LoadTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/LoadTest.php
@@ -82,7 +82,7 @@ class LoadTest extends FileManagedTestBase {
// 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.'));
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
index 8447031..7764699 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
@@ -78,7 +78,7 @@ class UserPictureTest extends WebTestBase {
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 @@ class UserPictureTest extends WebTestBase {
// 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);
}
}