The Context sets empty regions to empty arrays in context_page_build. This can confuse themes/modules that use isset to test for empty regions in hook_preprocess_html's $vars for example.

The patch below adjusts the code to only set the region if context has blocks to place in the region. (I'll attach the below as a patch file in the first comment).

     // Load all region content assigned via blocks.
     foreach (array_keys($all_regions) as $region) {
       if ($this->is_enabled_region($region)) {
-        $page[$region] = isset($page[$region]) ? array_merge($page[$region], $this->block_get_blocks_by_region($region)) : $this->block_get_blocks_by_region($region);
+        if ($blocks = $this->block_get_blocks_by_region($region)) {
+          $page[$region] = isset($page[$region]) ? array_merge($page[$region], $blocks) : $blocks;
+        }
       }
     }
   }
Files: 
CommentFileSizeAuthor
#1 context-empty-regions-1100610-1.patch760 bytessetvik

Comments

StatusFileSize
new760 bytes

Status:Active» Needs review

Here is an example of a theme's implementation of html preprocess function which is using isset that causes this issue:

  <?php
   
function mytheme_preprocess_html(&$vars) {
     
$vars['classes_array'][] = 'layout-'. (isset($vars['page']['sidebar_first']) ? 'first-main' : 'main') . (isset($vars['page']['sidebar_second']) ? '-second' : '');
    }
 
?>

Version:7.x-3.0-beta1» 7.x-3.x-dev

Priority:Normal» Major

Status:Needs review» Closed (fixed)