#markup is supposed to be rendered by drupal_render() as a "fallback" when there is no theme() implementation available to handle the current renderable array.

In the case that #theme is an array of suggestions passed to theme() but none are implemented, #theme is set but theme() will return an empty string. In this case #markup should be rendered by drupal_render() if it is set but currently this is not what happens.

Current code:

  if (!isset($elements['#theme']) && isset($elements['#markup'])) {
    $elements['#children'] = $elements['#markup'] . $elements['#children'];
  }

Simply checking for $elements['#children'] === '' is not a robust solution either, as this could mean a theme() implementation *was* found but it legitimately rendered an empty string.

As an example of where theme suggestions appear in array format in core, they are generated as defaults for every form automatically by drupal_prepare_form().

Related

- #2012812: drupal_render() can't distinguish between empty strings from theme() and no hook being matched

Comments

thedavidmeister’s picture

Status: Active » Closed (duplicate)