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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1126544-block-custom-bid-delta-2.patch | 2.82 KB | Niklas Fiekas |
| #1 | block-custom-bid-delta-1126544-1.patch | 2.82 KB | Niklas Fiekas |
Comments
Comment #1
Niklas Fiekas commented(Naive) patch attached.
Comment #2
Niklas Fiekas commentedSorry. 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.
Comment #3
tlangston commentedtested this and confirm breakage
Comment #4
Niklas Fiekas commentedLet's see what the testbot says. I guess it breaks everything.
Comment #6
Niklas Fiekas commentedThis is a duplicate of #966556: Update custom_block_schema() description for the bid field.