If you have a temporary file and for some reason the file on the disk for it no longer exists, it logs an error every time file_cron() runs.

Proposed resolution

The file is gone. Maybe log an error or warning once, then drop the record.

Remaining tasks

User interface changes

API changes

Data model changes


Berdir created an issue. See original summary.

slashrsm’s picture

Status: Active » Needs review
1.16 KB

Something along those lines?

dawehner’s picture

That's non trivial given that many systems drop log messages quite quickly, so potentially you'll never see the message.

Berdir’s picture

Yes, that's true for all log messages yes, also like content being deleted. But it's better than spaming the log and causing even more useful messages to get lost :)

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Berdir’s picture

Re-rolled and included the test from #2760347: file_cron does not remove orphaned entries. Will close that as duplicate. Please also credit those from that issue. Will also close #2850497: Unclear log message when CRON garbage collection is unable to clean up temporary files as duplicate.

Berdir’s picture

Berdir’s picture

For the record, we're seeing this from time to time on our systems, haven't been able to track down what exactly is causing it yet, but as I said, the file is gone and we wanted to delete it anyway.

The last submitted patch, 6: 2802803_6-test-only.patch, failed testing.

The last submitted patch, 6: 2802803_6-test-only.patch, failed testing.

Munavijayalakshmi’s picture

+++ b/core/modules/file/file.module
@@ -659,12 +659,10 @@ function file_cron() {
+          \Drupal::logger('file system')->warning('Temporary file "%path" that was deleted during garbage collection did not exist on the filesystem.', array('%path' => $file->getFileUri()));

+++ b/core/modules/file/tests/src/Kernel/DeleteTest.php
@@ -69,4 +69,29 @@ public function testInUse() {
+      ->fields(array(
+        'changed' => \Drupal::time()->getRequestTime() - ($this->config('system.file')->get('temporary_maximum_age') + 1),
+      ))

use short array syntax (new coding standard).

Fixed the short array syntax error.

LittleCoding’s picture

This error can also be triggered via the read permissions of the file being misconfigured. So it does not look like a good practice to force a delete in this case.

gapple’s picture

Closed #2725457: Managed file garbage collector should delete file entity even if physical file does not exst. as a duplicate. The major difference in the patch in that issue is that it also performs an is_writable() check if the file still exists.

gapple’s picture

In the comments for #1401558: Remove the usage handling logic from file_delete() where the file_exists() check was added, there was also a concern about deleting the file entity if the stream wrapper was only disabled.