Problem/Motivation

The file system CRON is gives a somewhat unclear error message in logs when a temporary files can not be deleted because the have already been removed or due to permissions the file is not accessible.

The file system records the following Error in the logs: Could not delete temporary file "temporary://AAA.pdf" during garbage collection

Proposed resolution

Improve error message for logging

Remaining tasks

  • Define new error message
  • Update error message

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#10 drupal-2850497-10.patch668 byteslittlecoding

Comments

LittleCoding created an issue. See original summary.

cilefen’s picture

If it helps, file_cron() does the following:

        if (file_exists($file->getFileUri())) {
          $file->delete();
        }
        else {
          \Drupal::logger('file system')->error('Could not delete temporary file "%path" during garbage collection', array('%path' => $file->getFileUri()));
        }
littlecoding’s picture

The file does exist in the temp directory still. And I have ruled out the PHP safe mode restrictions in this case.

But if the error is triggered by the file_exists(string $filename) function, I think the wording of the message could be improved. Something along the lines of :

Could not delete temporary file "%path" during garbage collection. Temporary file not found or inaccessible due to safe mode restrictions.

with a link to the PHP safe mode page http://php.net/manual/en/features.safe-mode.php

cilefen’s picture

Safe mode doesn't exist any more. There is not an error triggered by the call to file_exists(). It is returning FALSE.

littlecoding’s picture

Odd. Those are the only to reason the PHP doc list for returning FALSE.

A manual delete of the temporary file works via the admin UI provided by contrib module File Entity. I have also tried this manual delete method on a file that no longer exists in the temp directory and it works fine.

cilefen’s picture

You must be reading different docs from me ;-).

file_exists() returns false if the file does not exist. If false, the message is logged.

littlecoding’s picture

Yep those are the reasons I was (I guess poorly) referring to. More work on those PHP log files then to give more insight on the issue.

littlecoding’s picture

Category: Bug report » Feature request
Issue summary: View changes

After a few days of allowing the site to function as normal and watching the logs, I've managed to identify that a server function is occasionally clearing out files from the temporary directory before the Drupal CRON garbage collection has a chance to clean up after itself. Default timing of these CRON job looking to remove a file like is is 6 hours, that is also the shortest time option give in the admin dashboard by core. I don't feel a shorter time interval needs to be added, rather a better error message in the watchdog could help site admins who may also run into this issue. So I have change the Category of the issue from Bug Report to Feature request, updated the title and issue description.

How about this for the improved error message?

Could not delete temporary file "%path" during garbage collection. File was not found or was not accessible.

littlecoding’s picture

Title: CRON unable to clean up temporary files » Unclear log message when CRON garbage collection is unable to clean up temporary files
littlecoding’s picture

Category: Feature request » Bug report
Issue tags: +Needs tests
StatusFileSize
new668 bytes
littlecoding’s picture

Status: Active » Needs review
berdir’s picture

Status: Needs review » Closed (duplicate)