A maximum length for the machine name field should be kept at 32 characters because the delta column for the blocks tables is only 32 character in length.

Comments

bleen’s picture

Status: Active » Fixed

nice catch - thanks!

This has been committed to 7.x-2.x-dev http://drupalcode.org/project/dart.git/commit/bd0e021

cntlscrut’s picture

Priority: Normal » Major
Status: Fixed » Active

I reopened this ticket as I found that even with the character limit, the block build is prepending the block machine name with "dart-tag-" which for a user given machine name over 23 chars maxes out the column length and causes this error:

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] => dart [:db_insert_placeholder_1] => dart-tag-testing_for_a_really_long_name_b [:db_insert_placeholder_2] => bartik [:db_insert_placeholder_3] => 0 [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => -1 [:db_insert_placeholder_6] => ) in drupal_write_record() (line 6888 of /web/jam.geoffmaxey.com/html/includes/common.inc).

cntlscrut’s picture

StatusFileSize
new475 bytes

So, after some searching I found that the info array in the hook_block_info implementation was adding the "dart-tag-" prefix to the block delta (which can only be 32 chars in length).

I found that by removing that prefix and sticking with the 32 maxlength value from the earlier patch prevented this from occurring.

So, here's a patch for consideration in this issue:

bleen’s picture

here's my problem ... if I remove the prefix from hook_block_info() I need to remove it from hook_block_view also ... and if I do that then I need to update the deltas for all existing blocks in the database.... and if I do THAT then the id will change on DART blocks and that can mess up people's css

Hmmmmmm... any ideas?

cntlscrut’s picture

So, I did some further testing to determine the effect of that change and found that it did not hender anything.
- The hook_block_view is removing the "dart-tag" prefix from the delta before checking/loading the block which doesn't affect the block loading.
- the css classes are not affected by the change.
- The main thing that i did find was that when the hook_block_info was run again there were duplicates of the blocks in there.

The dups in the db were the only main problem that i ran across. A quick update script could fix that. The only thing I would want to double check is how to maintain block placement post an update and check that for sites using features, that the block values would either translate or cause dups, as well.

I don't mind building the update.

thoughts?

bleen’s picture

is the ID effected? In theory some people may have css defined for the ID of their blocks. Other than that, I would be happy to review your patch if it includes an update function to (hopefully) remedy this in a non-destructive way.

bleen’s picture

Status: Active » Closed (won't fix)
StatusFileSize
new2.57 KB

I was going to commit the attached patch, but I realize that this will break any site using context or panels to place blocks. Basically, it is unacceptable to change the delta of a block without totally borking people's sites.

For this reason, I'm marking this "wont fix".