There is a little logical bug in the function mail_edit_features_content_get().
Problem:
The problem is, that it does not return any value if there are entries in the {mail_edit_registry} but NOT in the {mail_edit} table.
That leads to a secondary error at import. In function mail_edit_features_features_rebuild($module) the existence of the entries is checked but in the current implementation there will always be a DUPLICATE KEY database error on import in the following context!
Context:
This is the case for example, if a module like subscriptions.module (real case!!) adds predefined but empty registry entries. These entries have no corresponding {mail_edit} entries.
Solution:
The (tested) solution is simply to use a left join on the {mail_edit} table and return the ID from the {mail_edit_registry} mer table.
So the query returns all registry entries but without a language if there is no text for that entry yet.
It works great.
/**
* Get current settings for mail_edit.
*/
function mail_edit_features_content_get() {
$query = db_query('SELECT mer.id, me.language FROM {mail_edit_registry} mer' .
' LEFT JOIN {mail_edit} me ON me.id = mer.id');
$templates = array();
// Collect templates on all available languages.
foreach ($query as $result) {
// language is NULL if no translation exists for the registry entry.
$templates[$result->id][] = $result->language;
}
return $templates;
}
I've set this to major because the module functionality is completely broken with a database error for the real use case of subscriptions.module for example.
Thanks a lot.