Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The uri column in {file_managed} is defined as unique. In Media 2.x, file_uri_to_object() by default reuses an existing fid, but to not break backwards compatibility, that is not the default in Media 1.x. To avoid a PDO exception, the provider must either implement a validate() method that throws an exception that media_internet then displays as a form_set_error(), forcing the user to enter a unique URL, or else pass TRUE to file_uri_to_object(), allowing the Media browser to simply return the already existing fid.
This patch does the latter.
Comment | File | Size | Author |
---|---|---|---|
#1 | 1298562-1.oembed-duplicate-uri.patch | 939 bytes | ksenzee |
oembed-duplicate-uri.patch | 480 bytes | effulgentsia |
Comments
Comment #1
ksenzeeThe patch above keeps the user from getting an error when they enter a duplicate URL, and fixes the UX in most situations. I'm attaching a patch that also updates the timestamp when re-saving the piece of media, so the newly (re)embedded media shows up at the top of the list in admin/content/media, where the user would expect it to be. (Note that this addition was also effulgentsia's idea - I just agreed with him and wrote the patch.)
Comment #2
effulgentsia CreditAttribution: effulgentsia commented#1 looks great to me, so RTBC. I worked on part of this patch, so if you want to bump it back to "needs review", I'll understand.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedCommitted. Thanks! http://drupalcode.org/project/oembed.git/commit/0e7f47991d98e0ce7150e4fc...