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

    I' tried to config an existin block and asign it to an existing region.
  • 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
The warnings
  • warning: Illegal string offset 'region' in /home/user/lampstack-5.4.11-0/apache2/htdocs/mlyteal/modules/block/block.admin.inc on line 101.
  • warning: Illegal string offset 'status' in /home/user/lampstack-5.4.11-0/apache2/htdocs/mlyteal/modules/block/block.admin.inc on line 101.
  • warning: Illegal string offset 'status' in /home/user/lampstack-5.4.11-0/apache2/htdocs/mlyteal/modules/block/block.admin.inc on line 102.

    ...

    at least 40 more lines

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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dddave’s picture

Project: Drupal.org site moderators » Drupal core
Version: » 6.x-dev
Component: Other » block.module
TJ’s picture

Patch for this issue.

TJ’s picture

Status: Active » Needs review
FileSize
1.29 KB

Patch for this issue.

TJ’s picture

Issue summary: View changes

A repost to show the solution

ibnkhaldun’s picture

Issue summary: View changes
Status: Needs review » Closed (fixed)

Thank you for revisions.