unl/UNL_MediaHub — pull request #208 by mfairchild365 (2014-11-25 22:34:26+00:00)
Title: Fix integrity constraint violations

Fixes #206

Seemingly random integrity constraint violations were being seen when saving media. It was not very reproducible. They key violation was `0-media-content` which fits the primary key for the `media_has_nselement` table. There already exists a record in the database with that key even though no media record exists with an id of '0'.

I think the issue is that `getFieldValue($context, 'media', 'id');` always returns `null`. And thus doctrine would try to insert a record with a media_id of zero. I'm not sure how it sometimes worked but not other times, probably something to do with the doctrine internals.

As you can see with the rest of the inputs, none of them specify a media_id, I'm assuming because doctrine knows how to link the records. Thus, removing them should solve the problem.