The documentation should mention that the maximum length of the info attribute is 32 characters. I have a module with a particularly long name (pending_user_notification) and in trying to namespace my block, I was receiving an error when attempting to go to the block management page.

CommentFileSizeAuthor
#8 1025372.patch808 bytesrschwab
#4 1025372.patch847 bytesrschwab
#4 1025372.patch847 bytesrschwab
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

Title: Documentation problem with hook_block_info » hook_block_info should document max length of delta/array key

Hmmmm....

The maximum length of the array key on the return value (the "delta") is 32 bytes, as you can see from block_schema():

      'delta' => array(
        'type' => 'varchar', 
        'length' => 32, 
        'not null' => TRUE, 
        'default' => '0', 
        'description' => 'Unique ID for block within a module.',
      ), 

I think that is what you are talking about, since you mention a value of 'pending_user_notification'. That would typically be a block delta, not a 'info' element. I agree this maximum should be documented, and it isn't currently.

I don't think there's really a maximum length for the 'info' element of the return value though -- that is the default human-readable title for the block, and it is not stored in the database as far as I can tell. I looked through _block_rehash(), which builds the block list for the block admin page, and I'm not seeing any usage of the 'info' component that would have a maximum length.

There is also a maximum length for the human-readable title that someone configures in the user interface, which is apparently 64 bytes:

     'title' => array(
        'type' => 'varchar', 
        'length' => 64, 
        'not null' => TRUE, 
        'default' => '', 
        'description' => 'Custom title for the block. (Empty string will use block default title, <none> will remove the title, text will cause block to use specified title.)', 
        'translatable' => TRUE,
      ), 

So I'm assuming you meant the array key and not the 'info' component? If not, what error are you getting?

Jaypan’s picture

Yes, I am referring to the delta, the key of the array. 32 bytes actually seems a little small to me (because of namespacing), but if it's going to be 32, then it should at least be documented. I was able to debug it from the error message and seeing the size in the database, but I know error messages like that can be confusing for some people, particularly when learning a new system.

jhodgdon’s picture

Issue tags: +Novice

Agreed, the 32 byte limit of delta needs to be documented. Good project for a novice doc contributor.

rschwab’s picture

Status: Active » Needs review
FileSize
847 bytes
847 bytes

This patch adds "The maximum length for delta values is 32 characters." to the paragraph describing delta values.

Jaypan’s picture

Looks good to me.

jhodgdon’s picture

Status: Needs review » Needs work

The maximum length is 32 *bytes*, not 32 characters. Not the same thing in, for instance, Japanese.

Jaypan’s picture

Heh, I'm in Japan and should have realized that!

rschwab’s picture

Status: Needs work » Needs review
FileSize
808 bytes

Oops! This one changes 'characters' to 'bytes'.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine, thanks!

jhodgdon’s picture

#8: 1025372.patch queued for re-testing.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -Novice

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

donquixote’s picture