The code of the function block_block_view($delta = '') is:

function block_block_view($delta = '') {
  $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
  $data['subject'] = NULL;
  $data['content'] = check_markup($block->body, $block->format, '', TRUE);
  return $data;
}

This looks like it will lookup by the bid. It will however look up by the (numeric) delta of the block.

The description of the schema states that wrong, as well:

$schema['block_custom'] = array(
  'description' => 'Stores contents of custom-made blocks.',
  'fields' => array(
  'bid' => array(
    'type' => 'serial',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'description' => "The block's {block}.bid.",
  ),
  // [...]
);

Relying on the wrong docs here leads (of course) to:

Notice: Trying to get property of non-object in block_block_view() (line 246 of /var/www/consolero/modules/block/block.module).

And of course you can't join {block} and {block_custom} by bid, as you would expect. You must join by the deltas and the condition module='block'.

I think this should be changed to delta in all cases.

-- Kind regards, Niklas

Comments

Niklas Fiekas’s picture

StatusFileSize
new2.82 KB

(Naive) patch attached.

Niklas Fiekas’s picture

StatusFileSize
new2.82 KB

Sorry. Next try.
I think it will break the custom block tests though, if they rely on the column name bid.

The other way would be to change the block.module to actually use the bid and not the delta.

tlangston’s picture

tested this and confirm breakage

Niklas Fiekas’s picture

Status: Active » Needs review

Let's see what the testbot says. I guess it breaks everything.

Status: Needs review » Needs work

The last submitted patch, 1126544-block-custom-bid-delta-2.patch, failed testing.

Niklas Fiekas’s picture

Status: Needs work » Closed (duplicate)