Solving illegal string offset 'region' and 'status' when saving block admin

This commit is contained in:
Manuel Cillero 2017-07-25 17:47:41 +02:00
parent 42540d1310
commit 8bc400de2a

View file

@ -98,9 +98,13 @@ function block_admin_display_form(&$form_state, $blocks, $theme = NULL) {
*/ */
function block_admin_display_form_submit($form, &$form_state) { function block_admin_display_form_submit($form, &$form_state) {
foreach ($form_state['values'] as $block) { foreach ($form_state['values'] as $block) {
$block['status'] = $block['region'] != BLOCK_REGION_NONE; // Avoid illegal string offset when saving block admin:
$block['region'] = $block['status'] ? $block['region'] : ''; // https://www.drupal.org/node/1680614#comment-7181392
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']); if (is_array($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.')); drupal_set_message(t('The block settings have been updated.'));
cache_clear_all(); cache_clear_all();