Jen, thanks so much for this, it's far far preferable to the terrible UI of the media module in Drupal 7.

I'm migrating content from emfields in an older version of a site. This URL was working some months ago, but now appears to be broken:

http://www.youtube.com/watch?v=OTIh3T9RHIc

Adding such a url to a youtube field results in this PDO exception:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_tour_video_video_id' at row 1: INSERT INTO {field_data_field_tour_video} (entity_type, entity_id, revision_id, bundle, delta, language, field_tour_video_input, field_tour_video_video_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 255 [:db_insert_placeholder_2] => 1036 [:db_insert_placeholder_3] => tour [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => http://www.youtube.com/watch?v=OTIh3T9RHIc&feature=related [:db_insert_placeholder_7] => OTIh3T9RHIc&feature=related ) in field_sql_storage_field_storage_write() (line 448 of /Volumes/Opus Locus/Sites/_drupal7/core/modules/field/modules/field_sql_storage/field_sql_storage.module).

This is only likely to happen when migrating content, but I imagine you'll wind up with many users of this module doing exactly that.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

John Pitcairn’s picture

Ermm, actually, now the YouTube link above works again. But the error the browser was returning while broken was "the document contains no data", if that's of any use.

John Pitcairn’s picture

Title: PDO exception on broken URLs » PDO exception on some URLs

Hmm, no, now I'm getting this when attempting to add a working YouTube URL:

http://www.youtube.com/watch?v=eY-eyZuW_Uk&feature=fvwrel

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_tour_video_video_id' at row 2: INSERT INTO {field_data_field_tour_video} (entity_type, entity_id, revision_id, bundle, delta, language, field_tour_video_input, field_tour_video_video_id) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7), (:db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12, :db_insert_placeholder_13, :db_insert_placeholder_14, :db_insert_placeholder_15); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 138 [:db_insert_placeholder_2] => 1038 [:db_insert_placeholder_3] => tour [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => http://www.youtube.com/watch?v=qDRLoNyF74U [:db_insert_placeholder_7] => qDRLoNyF74U [:db_insert_placeholder_8] => node [:db_insert_placeholder_9] => 138 [:db_insert_placeholder_10] => 1038 [:db_insert_placeholder_11] => tour [:db_insert_placeholder_12] => 1 [:db_insert_placeholder_13] => und [:db_insert_placeholder_14] => http://www.youtube.com/watch?v=eY-eyZuW_Uk&feature=fvwrel [:db_insert_placeholder_15] => eY-eyZuW_Uk&feature=fvwrel ) in field_sql_storage_field_storage_write() (line 448 of /Volumes/Opus Locus/Sites/_drupal7/core/modules/field/modules/field_sql_storage/field_sql_storage.module).

Removing "&feature..." from the URL appears to fix this, but I think users are likely to just paste the whole URL, and it might be preferable if the module just strips that off before storage?

Dave Reid’s picture

terrible UI of the media module in Drupal 7

@John Pitcairn: I would be interested to have you file an issue in Media with constructive criticism with where we are going wrong and how we can improve it in the Media module. Without input and valid criticism we can't really improve. Feel free to ping me in IRC any time to discuss.

jenlampton’s picture

Title: PDO exception on some URLs » PDO exception when youtube video URL has additional parameters appended

Hi John,

I haven't added any validation to the youtube URL to make sure that it's still working at youtube - but that would be a useful addition.

I'll also make sure that the additional parameters in the query string (that's the &feature=fvwrel at the end) don't also get saved into the database - that's what's causing the PDO error.

Thanks for pointing this out :)

jenlampton’s picture

Status: Active » Fixed

Fix committed to dev version.

jenlampton’s picture

Version: » 7.x-1.0-alpha2
Status: Fixed » Active

Re-opening this issue since #1412852: Cannot send Youtube ID points out that it's still possible to trigger the PDO error.

Problematic video URL is http://youtu.be/DHhStXYQusA?hd=1

guschilds’s picture

Status: Active » Needs review
FileSize
554 bytes

YouTube URLs formatted similar to http://youtu.be/DHhStXYQusA?hd=1 contain the ID before '?' rather than as the first parameter. While the ID is grabbed from a typical URL by removing everything after the first '&', the ID from these URLs must be grabbed by removing everything after '?'.

The attached patch does so.

Hope this helps.

jenlampton’s picture

Status: Needs review » Fixed

Attached patch resolves the problematic URL pattern. Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.