I get the following error when I enable one of my blocks with ESI integration:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'delta' at row 1: INSERT INTO {block} (module, delta, theme, status, weight, region, pages) 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] => esi_block [:db_insert_placeholder_1] => s17_named_geolocation_user_address [:db_insert_placeholder_2] => mercydotnet [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => -1 [:db_insert_placeholder_6] => ) in drupal_write_record() (line 7170 of /drupal/includes/common.inc).

As you can see, the second placeholder, s17_named_geolocation_user_address, is longer than 32 characters, thus causes the insert query to fail. Since esi_block__new_delta() adds 3-4 new characters to every block delta, and block deltas may already be up to 32 characters, we need more padding in the block delta column (or esi will need to change the way it creates placeholder block names).

CommentFileSizeAuthor
#1 2174205-1-esi-block-delta-fix.patch2.36 KBgeerlingguy
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geerlingguy’s picture

Status: Active » Needs review
FileSize
2.36 KB

The attached patch fixes the issue for me, by adjusting the block table's delta database field to 36 characters (from 32). Note that I didn't write an update function for this... it will need one added (which does the block delta adjustment as in hook_install) if this is the route we choose to go.

Another option would be to find a way to generate block deltas for ESI without going beyond 32 characters.

geerlingguy’s picture

Issue summary: View changes
sokrplare’s picture

Status: Needs review » Needs work

Super helpful patch - thanks!

I still ran into the limit at 36 because the Bean module keeps it's own separate table with 32-max deltas, but then when ESI adds the wrapper block the module name is also included in the new delta giving a 40 character total (s4_bean_Top-Menu-Login-and-Profile-Links). We could try 41/42 to handle that, but then what about others like Menu Bean?

Maybe it is safest to bump the block table delta max chars up to 255?

esolitos’s picture

I think the right approach would be to check for delta lengths in this module instead of changin the db structure, since other modules could rely on that (like apparently Manu Bean).

killes@www.drop.org’s picture

I think changing the core block table is a bad idea. Views used to run into an issue like this and is now storing a hash if the delta gets too long. Is that an option here?