I had a strange error when saving the settings for the search_api saved_searches module, where metatags was trying to:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'entity_type' at row 1: INSERT INTO {metatag} (entity_type, entity_id, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => search_api_saved_searches_settings [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => a:0:{} ) in metatag_metatags_save() (line 308 of /var/www7/sites/all/modules/metatag/metatag.module).

"search_api_saved_searches_settings" is obviously longer than the current 32 characters, which was creating the error. I had to increase the size of the entity_type field to be able to save my form.

CommentFileSizeAuthor
#2 metatag-n1504182-2.patch921 bytesdamienmckenna

Comments

damienmckenna’s picture

Title: 32 varchar limit on entity_type field » Increase entity_type field length to match core's VARCHAR(128)
Issue tags: +D7 stable release blocker

Drupal 7 core uses a VARCHAR(128) column to store the entity_type, so Metatags should do likewise.

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new921 bytes

This patch expands the column to VARCHAR(128), as described above.

dave reid’s picture

Status: Needs review » Needs work

No, this is incorrect. Entity type is in fact limited to 32 characters. See #1191434: Standardize entity type is a maximum of 32 characters (not 64 or 128). We should also probably *not* save a record if the metatags array is empty instead.

damienmckenna’s picture

Title: Increase entity_type field length to match core's VARCHAR(128) » Increase entity_type field length to match core
Status: Needs work » Postponed

Dave, I don't think we can say "entity_type is 32 characters" until Drupal core's inconsistency is fixed via that issue, until then we need to postpone this.

dave reid’s picture

Well the simple fact is that for any fieldable entities you are in fact limited to 32 characters otherwise you are not able to add fields on those entity types since saving to field_config_instance will fail.

dave reid’s picture

Issues that are postponed cannot be a release blocker.

damienmckenna’s picture

Status: Postponed » Closed (won't fix)

Dave's rationale in #5 above should suffice.