Thanks for adding the functionality to add meta tags to paths, even the meta keywords and not just ignoring the issue with a link to a site explaining why they're not important. (We all know met keywords don't matter for SEO, but try convincing a computer illiterate person who's been told by their trusted friend so-and-so that they are. :)

I've got meta tags working for paths, but when the description entered is too long, it results in a SQL error. It does not check the length before attempting the INSERT and prompt the user to correct like on nodes.

This occurred in both alpha4 and dev.

Here is the error that's produced:
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_meta_description_metatags_quick' at row 1: INSERT INTO {field_data_field_meta_description} (entity_type, entity_id, revision_id, bundle, delta, language, field_meta_description_metatags_quick) 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); Array ( [:db_insert_placeholder_0] => metatags_path_based [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1 [:db_insert_placeholder_3] => metatags_path_based [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pellentesque facilisis erat id sodales. Etiam bibendum nunc convallis lectus laoreet dignissim eu vitae turpis. Sed adipiscing nibh non dolor cursus et gravida velit semper. Proin faucibus sem nec eros scelerisque quis rhoncus ante molestie. Proin euismod aliquam pulvinar. Donec eget nisi eget sapien suscipit pretium. Fusce sed magna aliquet lorem suscipit rhoncus quis sit amet enim. Morbi sem nibh, hendrerit vitae posuere congue, ornare sed libero. Aliquam nec lorem diam, ut facilisis nisi. Vestibulum sit amet enim non ipsum elementum rutrum nec sit amet ligula. Integer elit orci, commodo in venenatis id, vehicula sed justo. Suspendisse lacus ipsum, elementum ac tempus eu, tincidunt nec est. Vestibulum commodo sem vitae eros molestie sit amet pellentesque turpis venenatis. ) in field_sql_storage_field_storage_write() (line 424 of /home/clients/websites/w_vista/public_html/vista/modules/field/modules/field_sql_storage/field_sql_storage.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

valthebald’s picture

Status: Active » Fixed
Issue tags: +Path based meta tags
FileSize
527 bytes
cwithout’s picture

Patch works. Thanks.

Status: Fixed » Closed (fixed)

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

osopolar’s picture

Status: Closed (fixed) » Needs work

I updated to current dev. Although this was marked fixed I get still the PDOException if the description is too long (256 or characters).

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'meta_description_metatags_quick' at row 1: INSERT INTO {field_data_meta_description} (entity_type, entity_id, revision_id, bundle, delta, language, meta_description_metatags_quick) 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); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 26 [:db_insert_placeholder_2] => 33 [:db_insert_placeholder_3] => tour [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123451 ) in field_sql_storage_field_storage_write() (line 448 of /home/domain/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

valthebald’s picture

Status: Needs work » Postponed (maintainer needs more info)

That's strange. Do you experience that with path-based or node meta tags?
There is implementation of hook_field_validate (http://api.drupal.org/api/drupal/modules!field!field.api.php/function/ho...):

function metatags_quick_field_validate($obj_type, $object, $field, $instance, $langcode, $items, &$errors) {  
  if (!isset($field['settings']['max_length'])) {
    $field['settings']['max_length'] = 255;
  }
  foreach ($items as $delta => $item) {
    if (!empty($item['metatags_quick']) && !is_array($item['metatags_quick']) && drupal_strlen($item['metatags_quick']) > $field['settings']['max_length']) {
      $error = t('%name: the value may not be longer than %max characters.', array('%name' => $instance['label'], '%max' => $field['settings']['max_length']));
      $errors[$field['field_name']][$langcode][$delta][] = array(
        'error' => $error,
        'message' => $error,
      );
    }
  }
  return;
}
rv0’s picture

the problem is metatags_quick_field_widget_form does not ad the validator in its "default" fallback

to fix this, better add the correct textarea code

    case 'metatags_quick_textarea':
      $addition = array(
        '#type' => 'textarea',
        '#default_value' => isset($items[$delta]['metatags_quick']) ? $items[$delta]['metatags_quick'] : NULL,
        '#maxlength' => isset($field['settings']['max_length']) ? $field['settings']['max_length'] : variable_get('metatags_quick_default_field_length', 255),
        '#validate' => array('metatags_quick_field_validate'),
        '#rows' => 5,
      );
      break;
rv0’s picture

Status: Postponed (maintainer needs more info) » Needs review

see #6

valthebald’s picture

Shouldn't it be #element_validate, not #validate?

valthebald’s picture

Status: Needs review » Postponed (maintainer needs more info)

Can't reproduce this error, neither with path-based nor with node meta tags

rv0’s picture

@valthebald
looking at the latest version 7.x-2.7, I see there is no longer any #validate added in metatags_quick_field_widget_form.
so the code in #6 doesn't count any more and the issue is probably fixed.

the issue I had was in 7.x-2.5

valthebald’s picture

Status: Postponed (maintainer needs more info) » Fixed

Great, another fixed issue (hopefully)

osopolar’s picture

Status: Fixed » Needs work

I got the error with version 7.x-2.7 ... looking at the commit log it doesn't seem to be fixed in current dev neither.

valthebald’s picture

Maybe I'm missing something, but can't reproduce this.
Can you please explain what steps do you do to get this error?

valthebald’s picture

Status: Needs work » Postponed (maintainer needs more info)
osopolar’s picture

Status: Postponed (maintainer needs more info) » Needs work

I just typed in the node forms meta_description field (stored in field_data_meta_description) a text longer than 255 characters like:

1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456=260

The error message I got is:
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'meta_description_metatags_quick' at row 1: INSERT INTO {field_data_meta_description} (entity_type, entity_id, revision_id, bundle, delta, language, meta_description_metatags_quick) 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); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 100 [:db_insert_placeholder_2] => 354 [:db_insert_placeholder_3] => article [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456=260 ) in field_sql_storage_field_storage_write() (Zeile 448 von /home/web/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

Maximal field length in admin/structure/types/manage/article/fields/meta_description/field-settings is set to 255.

I haven't tested with a clean install yet. the update-history of the module since installation:

Installed version was 7.x-1.9 (in 2011), on Feb 02 2012 I updated to 7.x-2.3+3-dev, on Aug 10 2012 to 7.x-2.5 and finally on Jan 19 2013 to 7.x-2.7.

valthebald’s picture

Status: Needs work » Active

That's interesting. The issue may indeed be caused by incorrect settings coming from older versions, since clean install definitely doesn't have this problem.
Let me check it.
Also, setting this to 'Active' ('needs work' means there is already at least rough solution, which needs improvement)

litvinova_yana’s picture

Hi!

I have faced this problem as well.
version = "7.x-2.7"
"Default maximum length" in a "Global settings" section does not affect max length of the fields... They have 160 symbols max unchanged.

Please, help!

hockey2112’s picture

I also have this issue in 7.x-2.7. Any fix?

Here is my exact error message. The meta tag is lists is only 175 characters long.

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=3976&op=do StatusText: error ResponseText: PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'meta_description_metatags_quick' at row 1: INSERT INTO {field_data_meta_description} (entity_type, entity_id, revision_id, bundle, delta, language, meta_description_metatags_quick) 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); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 2 [:db_insert_placeholder_2] => 2 [:db_insert_placeholder_3] => product [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => This is my meta tag. This is my meta tag. This is my meta tag. This is my meta tag. This is my meta tag. This is my meta tag. This is my meta tag. This is my meta tag. This is ) in field_sql_storage_field_storage_write() (line 451 of /home/mysite/public_html/modules/field/modules/field_sql_storage/field_sql_storage.module).

MaximumHormone’s picture

Still having this same issue
Here is my error
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'language' at row 1: INSERT INTO {metatag} (entity_type, entity_id, language, revision_id, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 95 [:db_insert_placeholder_2] => twitter:player:stream:content_type [:db_insert_placeholder_3] => 95 [:db_insert_placeholder_4] => a:1:{s:5:"value";s:8:"Proprius";} ) in metatag_metatags_save() (line 555 of /Library/WebServer/Documents/Fun4Kids2/sites/all/modules/metatag/metatag.module).

line 555 is ->execute();

this is the whole block
// Update each of the per-language metatag configurations in turn.
foreach ($metatags as $langcode => $new_metatags) {
// Allow other modules to alter the meta tags prior to saving using
// hook_metatag_presave().
foreach (module_implements('metatag_presave') as $module) {
$function = "{$module}_metatag_presave";
$function($new_metatags, $entity_type, $entity_id, $revision_id, $langcode);
}

// If the data array is empty, there is no data to actually save, so just
// delete the record from the database.
if (empty($new_metatags)) {
db_delete('metatag')
->condition('entity_type', $entity_type)
->condition('entity_id', $entity_id)
->condition('revision_id', $revision_id)
->condition('language', $langcode)
->execute();
}
// Otherwise save the data for this entity.
else {
db_merge('metatag')
->key(array(
'entity_type' => $entity_type,
'entity_id' => $entity_id,
'language' => $langcode,
'revision_id' => $revision_id,
))
->fields(array(
'data' => serialize($new_metatags),
))
->execute();
}
}

was there any thing that was resolved using the latest 7 install?

Kamlendra’s picture

Issue still persists,

I've migrated D6 to D7, D6 version of my site was using nodewords module for metatags and now I'm using Meta tags quick module to migrate meta tags.

While migrating meta tags I got the same error, Error message from dblog is pasted here

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'meta_description_metatags_quick' at row 1: INSERT INTO {field_data_meta_description} (entity_type, entity_id, revision_id, bundle, delta, language, meta_description_metatags_quick) 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); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 403582 [:db_insert_placeholder_2] => 438563 [:db_insert_placeholder_3] => story [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => NEW SMYRNA BEACH - Dr. Arlen Stauffer, a physician and chairman of the NSB Balloon Fest, was chosen at tonight's City Commission meeting as New Smyrna Beach's nominee the Volusia Leaque of Cities' citizen of the year award. ) in field_sql_storage_field_storage_write() (line 514 of /var/www/headlines-surfer/modules/field/modules/field_sql_storage/field_sql_storage.module).

schifazl’s picture

I'm having this issue too