I am working with a site that has the 7.x-2.0-alpha3 versions of Media and File Entity installed, and there seems to be a conflict with some other module that is causing the file_entity_edit_validate() function not to fire when editing an existing file. The tipoff was that the form was submitting without error, but the file would not actually be updated. Using a debugger, I was able to determine that the validate function was never actually executing.

When I add the validate function explicitly, like this, everything works great:

  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 5,
    '#submit' => array('file_entity_edit_submit'),
    '#validate' => array('file_entity_edit_validate'),
  );

This problem does not occur when installing a clean site from the same codebase, and just enabling Media and File Entity, so the problem definitely seems to be coming from an interaction with another module (of which there are many). Any idea where to start looking for something that could be conflicting with that validate function executing on the basis of the name alone?

Thanks for any help you can offer!

CommentFileSizeAuthor
#2 file_entity-validate-not-executing-2.patch449 bytesthelmer

Comments

gravelpot’s picture

Just a quick update -- I looked for other modules that might be implementing hook_form_alter on the file_entity_edit form, and disabled the manualcrop and file_admin modules, but that didn't fix the problem. The only _form_file_entity_edit_alter hooks left that are being executed according to xhprof are:

  • pathauto_form_file_entity_edit_alter
  • path_form_file_entity_edit_alter
  • media_form_file_entity_edit_alter
thelmer’s picture

StatusFileSize
new449 bytes

There's a range of modules depending on the ability to add extra validation to file entities, eg. focal_point. When file_entity uses the magic filename conventions other modules can only replace the validation and not extend it.

If any such modules is installed the file_entity_edit validation handler will not be executed and things like replacing the file won't work.

I have added a patch explicitly adding the validation handler to the file_entity_edit form (exactly like the original issue suggests).

jeffschuler’s picture

Title: file_entity_edit_validate not executing » file_entity_edit_validate not executing: "Replace file" broken
Version: 7.x-2.0-alpha3 » 7.x-2.x-dev
Category: Support request » Bug report
Status: Active » Reviewed & tested by the community

Yes!
File replacement wasn't working for me. I tracked this down to the same issue -- the validate handler not firing -- and made the same fix, with success.
Marking as RTBC.
I'm adding to the issue title so others experiencing the symptom (but not knowing the problem) can more easily find this issue.

  • aaron committed cd23497 on 7.x-2.x
    Issue #2196819 by thelmer: file_entity_edit_validate not executing: "...
aaron’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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