Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 
  • _theme() now returns FALSE when the theme hook/suggestion passed to theme() is not found in the registry; otherwise _theme() returns the return value of the theme function/template.
  • drupal_render() will explicitly check for a FALSE return from _theme() before rendering children or #markup. drupal_render() only attempts to handle child elements and #markup if _theme() never built markup via a theme function or template.

Before:

<?php
// Output is 'foo'
$empty = array(
  '#theme' => 'theme_returns_empty',
  '#markup' => 'foo',
);

// Output is 'foo'
$empty = array(
  '#theme' => 'theme_returns_empty',
  'child' => array('#markup' => 'foo'),
);

// Output is 'foo'
$not_implemented = array(
  '#theme' => array('theme_not_implemented'),
  '#markup' => 'foo',
);
?>

After:

<?php
// _theme() intentionally returns an empty string. This should not be considered a falsey value. Output is '' (an empty string).
// Do not back off to the #markup key value.
$empty = array(
  '#theme' => array('theme_returns_empty'),
  '#markup' => 'foo',
);

// Output is '' (an empty string)
// Do not back off to the #markup key value.
$empty = array(
  '#theme' => 'theme_returns_empty',
  'child' => array('#markup' => 'foo'),
);

// The theme function is not implemented, so theme() returns FALSE. Output is 'foo'
// Back off to the #markup key value.
$not_implemented = array(
  '#theme' => array('theme_not_implemented'),
  '#markup' => 'foo',
);
?>
Impacts: 
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done