I've run into the following issue a couple of times in the past: when uploading a file, the upload fails for whatever reason (this has happened for various reasons - a space in the file name, using Japanese characters in the file name, setting the upload limit on one server, then migrating the site to another server with a smaller php upload limit). When clicking 'edit', then clicking the 'delete' button, the deletion fails, as the file name is empty so hook_validate() set's an error.
This can be fixed by checking to see if it is the delete button that has been fixed. I have changed hook_validate to be this on the sites I am running:
function flashnode_validate(&$node) {
if($node->op != $node->delete)
{
// Check a file has been uploaded
if (!$_FILES['files']['name']['flashfile'] && !$node->flashnode['filepath']) {
form_set_error('flashfile', t('You must upload a file.'));
}
// Check width is valid (if not empty it must be numeric)
if (!empty($node->flashnode['width']) && !is_numeric($node->flashnode['width'])) {
form_set_error('flashnode][width', t('You must enter a valid width.'));
}
// Check height is valid (if not empty it must be numeric)
if (!empty($node->flashnode['height']) && !is_numeric($node->flashnode['height'])) {
form_set_error('flashnode][height', t('You must enter a valid height.'));
}
}
return;
}
This checks to ensure that it wasn't the delete button that was pushed before performing validation, as the validation shouldn't be necessary when deleting a node.