We have a project where we use the Amazon S3 storage file system, and while testing various things, including deleting files, if an avatar image is not available, and we try to remove it via the admin form, we get this error:

admin/config/people/avatar_selection/edit/og/0?page=0 | 
Recoverable fatal error: Argument 1 passed to file_delete() must be an instance of stdClass, boolean given, called in /mnt/www/html/site/docroot/sites/all/modules/contrib/avatar_selection/avatar_selection.admin.inc on line 768 and defined in file_delete() (line 1272 of /mnt/www/html/works/docroot/includes/file.inc).

and deleting the avatar actually fails.

CommentFileSizeAuthor
#1 check_file_before_delete.patch833 bytesalcroito
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alcroito’s picture

FileSize
833 bytes

Attaching a patch that simply checks that a file exists, before trying to delete it.

federiko_’s picture

I'm using avatar selection in one of my projects and I met the same issue. The patch above worked so thank you! The next step would be to port this patch...