Problem/Motivation

I could be wrong about this but it appears that in ctools_block_content_type_render() if (empty($block)) is never true because just before it is $block = (object) $block; and therefore never returns early to prevent additional processing for an empty block.

The reason appears to be because as of PHP 5.0.0 "Objects with no properties are no longer considered empty".
source: http://php.net/manual/en/function.empty.php

function ctools_block_content_type_render($subtype, $conf) {
  list($module, $delta) = _ctools_block_get_module_delta($subtype, $conf);

  $info = _ctools_get_block_info($module, $delta);
  $block = module_invoke($module, 'block_view', $delta);

  if (!empty($info)) {
    // Allow modules to modify the block before it is viewed, via either
    // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
    drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info);
  }
  $block = (object) $block;

  if (empty($block)) {
    return;
  }

  $block->module = $module;

http://drupalcontrib.org/api/drupal/contributions%21ctools%21plugins%21c...

Proposed resolution

Move the $block = (object) $block; to be just after (empty($block)).

Remaining tasks

Review patch below.

User interface changes

None.

API changes

None.

Comments

elijah lynn’s picture

Status: Active » Needs review
StatusFileSize
new620 bytes

Status: Needs review » Needs work

The last submitted patch, 1: ctools-block-render-empty-block-return-2328787-1.patch, failed testing.

mrjmd’s picture

Status: Needs work » Needs review
StatusFileSize
new626 bytes

I verified that this is indeed an issue. Reroll attached.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Good to go.

mrjmd’s picture

japerry’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +SprintWeekend2015

Yup, works good for me too. Fixed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.