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).

Files: 

Comments

Status:Active» Fixed
Issue tags:+Path based meta tags
StatusFileSize
new527 bytes

Patch works. Thanks.

Status:Fixed» Closed (fixed)

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

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).

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;
}

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

<?php
   
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;
?>

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

see #6

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

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

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

@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

Status:Postponed (maintainer needs more info)» Fixed

Great, another fixed issue (hopefully)

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.

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

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

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/kennst-du-dresden.de/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.

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)

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!

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).