Hey there,

was just trying some things out, namely editing a webform and replacing one file with another and ran into a couple of issues which apparently come from the following code in the _webform_submit_file function components/file.inc

    // Delete any previous files.
    if ($value['_old'] && ($existing = webform_get_file($value['_old']))) {
      file_delete($existing->filepath);
      db_query("DELETE FROM {files} WHERE fid = %d", $existing->fid);
    }

Main issues here are:
1. file_delete in D7 takes the file object (in this case $existing) and not the filepath attribute (which actually doesn't exist anymore so that throws the first error)
2. the 2nd query is both invalid syntactically and also meaningless, as the files table doesn't exist in D7 anymore.

As I don't know exactly all the stuff that happens behind the scenes, I would dare to post a patch, but I assume you guys have enough to fix this up ;)

Cheers!

CommentFileSizeAuthor
#1 webform_file_delete-d7.patch501 bytesquicksketch

Comments

quicksketch’s picture

Title: Outdated code in _webform_submit_file » Outdated code in _webform_submit_file throws error when replacing files
Status: Active » Fixed
StatusFileSize
new501 bytes

Thanks! This is an easy fix since file_delete() now deletes the record for us. Committed attached patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.