Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
when the module is configured to use hook_file_presave, I receive an Ajax error when uploading the a new file from file/add or the media browser. I believe it is because $file does not have an assigned fid at that point.
An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/upload/form-tDcvECzYC1Lo2RUTxfVcMJOwagqDX8jsMGMmr_Jf9co
StatusText: n/a
ResponseText:
Error
Error message
Notice: Undefined property: stdClass::$fid in file_usage_list() (line 614 of /home/drupal/includes/file.inc).
Notice: Undefined property: stdClass::$fid in file_usage_add() (line 654 of /home/drupal/includes/file.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'fid' cannot be null: INSERT INTO {file_usage} (fid, module, type, id, count) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array
(
[:db_insert_placeholder_0] =>
[:db_insert_placeholder_1] => file_lock
[:db_insert_placeholder_2] => module
[:db_insert_placeholder_3] => 0
[:db_insert_placeholder_4] => 1
)
in file_usage_add() (line 661 of /home/drupal/includes/file.inc).
The website encountered an unexpected error. Please try again later.
ReadyState: undefined