From cafa95e68f1a4ef38c03ab04aec04534ede33d4f Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sun, 8 Jun 2014 21:42:53 -0500 Subject: [PATCH] Issue #2278025 by duellj | alexpott: Fixed Remove retrieveTemporaryFiles(). --- core/modules/file/src/FileStorage.php | 12 --- .../modules/file/src/FileStorageInterface.php | 12 --- .../src/Tests/RetrieveTemporaryFilesTest.php | 74 ------------------- 3 files changed, 98 deletions(-) delete mode 100644 core/modules/file/src/Tests/RetrieveTemporaryFilesTest.php diff --git a/core/modules/file/src/FileStorage.php b/core/modules/file/src/FileStorage.php index 4b30ad6a9586..1ec8fbf59962 100644 --- a/core/modules/file/src/FileStorage.php +++ b/core/modules/file/src/FileStorage.php @@ -27,18 +27,6 @@ public function spaceUsed($uid = NULL, $status = FILE_STATUS_PERMANENT) { return $query->execute()->fetchField(); } - /** - * {@inheritdoc} - */ - public function retrieveTemporaryFiles() { - // Use separate placeholders for the status to avoid a bug in some versions - // of PHP. See http://drupal.org/node/352956. - return $this->database->query('SELECT fid FROM {' . $this->entityType->getBaseTable() . '} WHERE status <> :permanent AND changed < :changed', array( - ':permanent' => FILE_STATUS_PERMANENT, - ':changed' => REQUEST_TIME - \Drupal::config('system.file')->get('temporary_maximum_age'), - ))->fetchCol(); - } - /** * {@inheritdoc} */ diff --git a/core/modules/file/src/FileStorageInterface.php b/core/modules/file/src/FileStorageInterface.php index 14bdc62797ab..2ec6d5045792 100644 --- a/core/modules/file/src/FileStorageInterface.php +++ b/core/modules/file/src/FileStorageInterface.php @@ -28,16 +28,4 @@ interface FileStorageInterface extends EntityStorageInterface { * An integer containing the number of bytes used. */ public function spaceUsed($uid = NULL, $status = FILE_STATUS_PERMANENT); - - /** - * Retrieves old temporary files. - * - * Get files older than the temporary maximum age, - * \Drupal::config('system.file')->get('temporary_maximum_age'). - * - * @return int[] - * A list of file IDs of the files to be deleted. - */ - public function retrieveTemporaryFiles(); - } diff --git a/core/modules/file/src/Tests/RetrieveTemporaryFilesTest.php b/core/modules/file/src/Tests/RetrieveTemporaryFilesTest.php deleted file mode 100644 index 12da31de2dc6..000000000000 --- a/core/modules/file/src/Tests/RetrieveTemporaryFilesTest.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -/** - * @file - * Contains \Drupal\file\Tests\RetrieveTemporaryFilesTest. - */ - -namespace Drupal\file\Tests; - -/** - * Provides tests for retrieving temporary files. - * - * @see \Drupal\Core\Entity\ContentEntityDatabaseStorage::retrieveTemporaryFiles() - */ -class RetrieveTemporaryFilesTest extends FileManagedUnitTestBase { - - /** - * The file storage. - * - * @var \Drupal\file\FileStorageInterface - */ - protected $fileStorage; - - /** - * The temporary_maximum_age setting of files. - * - * @var int - */ - protected $maxAge; - - /** - * {@inheritdoc} - */ - public static function getInfo() { - return array( - 'name' => 'Temporary files tests', - 'description' => 'Tests the retrieveTemporaryFiles() function.', - 'group' => 'File Managed API', - ); - } - - /** - * {@inheritdoc} - */ - public function setUp() { - parent::setUp(); - - $this->maxAge = $this->container->get('config.factory')->get('system.file')->get('temporary_maximum_age'); - $this->fileStorage = $this->container->get('entity.manager')->getStorage('file'); - // Create an entry for the user with the date change. - $file = $this->fileStorage->create(array('uid' => 2, 'uri' => $this->createUri(), 'status' => 2)); - $file->save(); - } - - /** - * Tests finding stale files. - */ - function testRetrieveTemporaryFiles() { - $this->assertEqual($this->fileStorage->retrieveTemporaryFiles(), [], 'No file is to be deleted.'); - - // Create an entry for the user with an indication of the old date of the - // change. As the changed field always saves the request time, we do have - // update it with a direct db query. - $file = $this->fileStorage->create(array('uid' => 2, 'uri' => $this->createUri(), 'status' => 2)); - $file->save(); - db_update('file_managed') - ->fields(array('changed' => REQUEST_TIME - ($this->maxAge * 2))) - ->condition('fid', $file->id()) - ->execute(); - - $this->assertEqual($this->fileStorage->retrieveTemporaryFiles(), [$file->id()], 'One file is to be deleted.'); - } - -} -- GitLab