From b44b2c6a97af4c8d865e724b139c6a26cbcadc33 Mon Sep 17 00:00:00 2001 From: Angie Byron <webchick@24967.no-reply.drupal.org> Date: Tue, 23 Nov 2010 16:12:15 +0000 Subject: [PATCH] #126070 follow-up by David_Rothstein: Rollback of previous patch; needs discussion/deferrment until D8. --- modules/block/block.api.php | 10 ++++++---- modules/block/block.module | 24 +++--------------------- modules/block/block.test | 4 ++-- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/modules/block/block.api.php b/modules/block/block.api.php index 9cc2f602e855..7b2ce0571d02 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 5cb0447d66af..db63be8b81ec 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 7c92a357db5f..30e91f617c34 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'; -- GitLab