The context.
1. I was working on a new module for drupal 6.x. Created a new set of blocks ( implemented hook_block() )
On testingn tasks I move a block from 1 region to another...
surprice!!!! I recived a full page of warnings.
2. I "read and reread" my code, made changes as posible, test again, always the same issue.
3. Got the idea ¿What happens if I have a clean drupal instalation? Install a new tests site, move a block, DONE the same issue
The issue
Drupal version: 6.28 (clean instalation, no extra modules, no changes, just instaled)
Module: Block
Server Apache Tomcat
SO Ubuntu 12.04
- the issue step by step
- go to page "?q=admin/build/block"
- Select the block "primary links"
- Asign It to header region using the "select field" on It's row.
- save changes
- drupal shows a page full of warnings
I' tried to config an existin block and asign it to an existing region.
The solution
Time ago I posted a similar issue for Drupal 6.24 when updating a site from 6.16. Then i found my site works thus forgot it.
Reading on posted replies I found there are an easy solution:
Go to file block.admin.inc and add a conditional test to the function: block_admin_display_form_submit(...) on line 99.
as i show:
The old function:
<?php
/**
* Process main blocks administration form submission.
* Original code
*/
function block_admin_display_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $block) {
$block['status'] = $block['region'] != BLOCK_REGION_NONE;
$block['region'] = $block['status'] ? $block['region'] : '';
db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s', throttle = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], isset($block['throttle']) ? $block['throttle'] : 0, $block['module'], $block['delta'], $block['theme']);
}
drupal_set_message(t('The block settings have been updated.'));
cache_clear_all();
}
?>
The patched function: Completely functional!!
<?php
/**
* Process main blocks administration form submission.
* PATCHED CODE
*/
function block_admin_display_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $block) {
if(is_array($block)){ // conditional patch line
$block['status'] = $block['region'] != BLOCK_REGION_NONE;
$block['region'] = $block['status'] ? $block['region'] : '';
db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s', throttle = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], isset($block['throttle']) ? $block['throttle'] : 0, $block['module'], $block['delta'], $block['theme']);
} // close conditional added
}
drupal_set_message(t('The block settings have been updated.'));
cache_clear_all();
}
?>
I repost it because i don't know why the patch reported there was not adopted on 6.28 release.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2004304-block-admin-inc.patch | 1.29 KB | TJ |
#2 | 2004304-block-admin-inc.patch | 1.29 KB | TJ |
Comments
Comment #1
dddave CreditAttribution: dddave commentedComment #2
TJ CreditAttribution: TJ commentedPatch for this issue.
Comment #3
TJ CreditAttribution: TJ commentedPatch for this issue.
Comment #3.0
TJ CreditAttribution: TJ commentedA repost to show the solution
Comment #4
ibnkhaldun CreditAttribution: ibnkhaldun commentedThank you for revisions.