To recreate the problem:
- create nodetype with a filefield and an emfield.
- create mediamover config that harvests files uploaded to this filefield, uploads them to youtube, and populates the emfield with the corresponding youtube-url's.
- create a node, and upload a file to this filefield.
- run the mediamover config

When the config is run, media_youtube adds entries to the database tables db.media_youtube_node_data and db.media_youtube_metadata, corresponding to the newly-generated youtube-url.

If the user now edits the node and deletes the file, then mm_emfield deletes the corresponding youtube-url. But the corresponding entries in the media_youtube database tables don't get deleted.

I am attaching a patch to mm_emfield_node_file_delete() that fixes the problem.

function mm_emfield_node_file_delete($configuration, $file) {
  ...
      if ($node_field['embed'] == $url) {
	if ($node_field['provider'] == 'youtube' && function_exists('media_youtube_emfield_field_extra_delete')){
	  // About to delete youtube-url.  Delete corresponding entries from media_youtube database tables
	 media_youtube_emfield_field_extra_delete($node_field['value'], $node->vid, $field, $key);
	}
        ...
      }
  ....

The function media_youtube_emfield_field_extra_delete() deletes the corresponding entries from the media_youtube database tables. This function is defined in a separate patch that I submitted to the media_youtube queue: http://drupal.org/node/1049234

CommentFileSizeAuthor
mm_emfield.bug25.diff337 byteskobnim