Hi,
the function media_file_delete should as pointed out in the comment within it use the following code
$media = media_load($file->fid);
module_invoke_all('entity_delete', $media, 'media');
field_attach_delete('media', $media);
to delete the attached field data of the entity. The media_browser_plus module for instance uses EntityFieldQuery to load media entities which returns positive hits containing deleted entity_ids if there is still field data that you query against.
I'll add the patch in a few minutes.
Comments
Comment #1
Sebastian.Buesing commentedAttached patch
Comment #2
effulgentsia commentedThis is now fixed in 7.x-1.x via the media entity to file entity refactoring in #1086958: Switch from Media Entity to File Entity. That refactoring broke Media Browser Plus, which now needs to be updated accordingly: #1139210: Call to undefined function media_browser_build_media_item() when using media-7.x-1.x-dev.