diff --git a/modules/block/block.api.php b/modules/block/block.api.php index 9cc2f602e855ceb4f06fc31f89e3c9acd98307d9..7b2ce0571d0214da3f2bade42b75aa2fc86a6b56 100644 --- a/modules/block/block.api.php +++ b/modules/block/block.api.php @@ -193,9 +193,11 @@ function hook_block_save($delta = '', $edit = array()) { * within the module, defined in hook_block_info(). * * @return - * An array containing required elements 'subject' (the block's localized - * title) and 'content' (the block's body). The 'content' element may be a - * renderable array (preferable) or rendered HTML content. + * An array containing the following elements: + * - subject: The default localized title of the block. If the block does not + * have a default title, this should be set to NULL. + * - content: The content of the block's body. This may be a renderable array + * (preferable) or a string containing rendered HTML content. * * For a detailed usage example, see block_example.module. * @@ -242,7 +244,7 @@ function hook_block_view($delta = '') { * @param $data * An array of data, as returned from the hook_block_view() implementation of * the module that defined the block: - * - subject: The localized title of the block. + * - subject: The default localized title of the block. * - content: Either a string or a renderable array representing the content * of the block. You should check that the content is an array before trying * to modify parts of the renderable structure. diff --git a/modules/block/block.module b/modules/block/block.module index 5cb0447d66af0f30d1f78a0c9f08a11609817f98..db63be8b81ec59dc42b1d25119e0f670c4231d0b 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -241,27 +241,9 @@ function block_block_save($delta = 0, $edit = array()) { * Generates the administrator-defined blocks for display. */ function block_block_view($delta = '') { - $query = db_select('block_custom', 'bc'); - $query->join('block', 'b', 'bc.bid = b.delta'); - $block = $query - ->addTag('translatable') - ->addTag('block_load') - ->fields('b', array('title')) - ->fields('bc', array('body', 'format')) - ->condition('bc.bid', $delta) - ->range(0, 1) - ->execute() - ->fetchObject(); - - $data = array( - // Only module-generated block titles are allowed to output any HTML markup. - // Custom block titles are always user input and therefore always escaped. - // @see _block_render_blocks() - 'subject' => $block->title == '<none>' ? '' : check_plain($block->title), - 'content' => array( - '#markup' => check_markup($block->body, $block->format), - ), - ); + $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject(); + $data['subject'] = NULL; + $data['content'] = check_markup($block->body, $block->format, '', TRUE); return $data; } diff --git a/modules/block/block.test b/modules/block/block.test index 7c92a357db5f362a9961cf3f2d75ab6ac7dcde78..30e91f617c34c264278f2d90183f7e44005c47f5 100644 --- a/modules/block/block.test +++ b/modules/block/block.test @@ -81,8 +81,8 @@ class BlockTestCase extends DrupalWebTestCase { // Check that block_block_view() returns the correct title and content. $data = block_block_view($bid); $format = db_query("SELECT format FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchField(); - $this->assertEqual($custom_block['title'], $data['subject'], t('block_block_view() provides correct block title.')); - $this->assertEqual(check_markup($custom_block['body[value]'], $format), $data['content']['#markup'], t('block_block_view() provides correct block content.')); + $this->assertTrue(array_key_exists('subject', $data) && empty($data['subject']), t('block_block_view() provides an empty block subject, since custom blocks do not have default titles.')); + $this->assertEqual(check_markup($custom_block['body[value]'], $format), $data['content'], t('block_block_view() provides correct block content.')); // Check if the block can be moved to all availble regions. $custom_block['module'] = 'block';