"The file was not deleted, because it does not exist."
The above notice occurs every time drupal_unmanaged_delete_recursive() is called with an invalid or nonexistent URI.
drupal_realpath() is used to convert the streamwrapper URI argument to a text string, but drupal_realpath() may also return FALSE on error. This error condition is never checked, so the following code calls drupal_unmanaged_delete(FALSE):
function file_unmanaged_delete_recursive($path) {
// Resolve streamwrapper URI to local path.
$path = drupal_realpath($path);
if (is_dir($path)) {
// ...
}
return file_unmanaged_delete($path);
}
A trivial patch to fix the problem follows:
--- includes/file.inc
+++ includes/file.inc
@@ -1305,6 +1305,9 @@ function file_unmanaged_delete($path) {
function file_unmanaged_delete_recursive($path) {
// Resolve streamwrapper URI to local path.
$path = drupal_realpath($path);
+ if ($path === FALSE) {
+ return;
+ }
if (is_dir($path)) {
$dir = dir($path);
while (($entry = $dir->read()) !== FALSE) {
Comments
Comment #1
pillarsdotnet commentedCorrected patch: The function documentation promises to return TRUE if the path does not exist.
There probably should be a test case for this, but I haven't learn how to write them yet.
Comment #2
pillarsdotnet commentedBah. Wish it were possible to edit the main text of an issue report -- I see where I called it "drupal_unmanaged_delete" instead of "file_unmanaged_delete". At least the patch has it correct.
EDIT: Still getting a few "The file was not deleted..." notices. Is it possible for drupal_realpath to return NULL or an empty string?
Comment #3
pillarsdotnet commentedOkay, this version kills all the notices.
Comment #4
pillarsdotnet commentedAnd without the prefixes which no doubt will confuse the testbot...
EDIT: removed invalid code patch.
Comment #6
pillarsdotnet commentedCorrected:
Comment #7
pillarsdotnet commentedComment #8
pillarsdotnet commentedBetter title.
Comment #9
adrinux commentedsub
Comment #10
SilviaT commentedsubscribe
Comment #11
hailaz commented+1
Comment #12
hailaz commentedThis is happening on /admin/modules/list/confirm in Drupal 7.0
Any ideas?
Comment #13
pillarsdotnet commentedYeah. Apply the patch in #6 and see if it fixes the problem for you.
Comment #14
hailaz commentedI'm on a mac and don't have snow leopard so can't download and use Xcode. I'm not a developer, it's way over my head, so to speak.
Will this cause issues on a live site before it's fixed?
I need to get this site up asap and want to use 7.
Thanks in advance and apologies for my lack of programming knowledge. I'd love to contribute but I'm kinda stuck at this point.
Comment #15
pillarsdotnet commentedThis is actually a minor issue. Leaving it "broken" will have no effect other than extra messages in your logs.
Comment #16
hailaz commentedThanks for that!
Comment #17
mchelenPatch from #6 fixed the error messages for me.
Comment #18
pillarsdotnet commentedComment #19
pillarsdotnet commented#6: file.inc_.patch queued for re-testing.
Comment #20
pillarsdotnet commentedSlightly different logic, and includes a commented-out watchdog line for those who want to debug the issue.
Comment #21
pillarsdotnet commentedBah. Typo. Still recovering from the Great Git Migration....
Uncommented the watchdog.
Comment #22
magnusk commentedapplied patch #6, the problem appears to be fixed. Thanks.
Comment #23
magnusk commentedI spoke too soon. Cron jobs run every hour on two sites hosted with two distinct servers. The message came back during the third cron run after patch on one server, and during the second cron run on another server.
The notice relates to the "Chaos tools" module:
Comment #24
pillarsdotnet commented@magnusk:
The originally-reported issue was an error message saying "The file was not deleted, because it does not exist."
Note the lack of a filename between the words "file" and "was". This makes troubleshooting the problem very difficult.
You have a totally different (and much more informative) error message. Obviously, something related to Chaos tools is passing a filepath with three consecutive dots in it. You should file an issue against the Chaos tools module accordingly.
Comment #25
magnusk commentedThe "..." was just me removing the specific path on my server, sorry if that was confusing. I've opened an issue in the ctools module. It seems like there are multiple issues involved?
Comment #26
pillarsdotnet commentedDunno. The patch in #21 definitely helps track down the real problem.
Comment #27
Mac Ryan commentedSubscribe
Comment #28
damien tournoud commentedActually those calls to drupal_realpath() needs to go away.
Marking as a duplicate of #1083982: Fix support for remote streamwrappers.
Comment #29
damien tournoud commentedRemoving tags.
Comment #30
OldAccount commentedPatch #6 is working for me, thank you!