Commit 3e9ae8f1 authored by webchick's avatar webchick

Issue #1880588 by tim.plunkett, sun: Fixed Regression: invalid HTML in menu...

Issue #1880588 by tim.plunkett, sun: Fixed Regression: invalid HTML in menu blocks due to _block_get_renderable_block() clobbering #theme_wrappers() of block contents.
parent 8b8c4202
......@@ -72,11 +72,11 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N
public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) {
$build = array();
foreach ($entities as $entity_id => $entity) {
$build[$entity_id] = $entity->getPlugin()->build();
// Allow blocks to be empty, do not add in the defaults.
if (!empty($build[$entity_id])) {
$build[$entity_id] = $this->getBuildDefaults($entity, $view_mode, $langcode) + $build[$entity_id];
if ($content = $entity->getPlugin()->build()) {
$build[$entity_id] = $this->getBuildDefaults($entity, $view_mode, $langcode);
}
$build[$entity_id]['content'] = $content;
// All blocks, even when empty, should be available for altering.
$id = str_replace(':', '__', $entity->get('plugin'));
......
......@@ -14,11 +14,6 @@
*/
class BlockHtmlIdTest extends WebTestBase {
/**
* An administrative user to configure the test environment.
*/
protected $adminUser;
/**
* Modules to enable.
*
......@@ -37,15 +32,14 @@ public static function getInfo() {
function setUp() {
parent::setUp();
// Create an admin user, log in and enable test blocks.
$this->adminUser = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
$this->drupalLogin($this->adminUser);
$this->drupalLogin($this->root_user);
// Make sure the block has some content so it will appear.
$current_content = $this->randomName();
state()->set('block_test.content', $current_content);
// Enable our test block.
// Enable our test blocks.
$this->drupalPlaceBlock('system_menu_block:menu-tools');
$this->drupalPlaceBlock('test_html_id', array('machine_name' => 'test_id_block'));
}
......@@ -55,6 +49,8 @@ function setUp() {
function testHtmlId() {
$this->drupalGet('');
$this->assertRaw('id="block-test-id-block"', 'HTML ID for test block is valid.');
$elements = $this->xpath('//div[contains(@class, :div-class)]/div/ul[contains(@class, :ul-class)]/li', array(':div-class' => 'block-system', ':ul-class' => 'menu'));
$this->assertTrue(!empty($elements), 'The proper block markup was found.');
}
}
......@@ -436,8 +436,8 @@ function menu_reset_item($link) {
function menu_block_view_alter(array &$build, Block $block) {
// Add contextual links for system menu blocks.
if ($block->getPlugin() instanceof SystemMenuBlock) {
foreach (element_children($build) as $key) {
$build['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($build[$key]['#original_link']['menu_name']));
foreach (element_children($build['content']) as $key) {
$build['#contextual_links']['menu'] = array('admin/structure/menu/manage', array($build['content'][$key]['#original_link']['menu_name']));
}
}
}
......
......@@ -166,15 +166,15 @@ function openid_user_logout($account) {
*/
function openid_block_view_user_login_block_alter(&$build, $block) {
// Only alter the block when it is non-empty, i.e. when no user is logged in.
if (!isset($build['user_login_form'])) {
if (!isset($build['content']['user_login_form'])) {
return;
}
$build['openid_login_form'] = drupal_get_form('openid_login_form');
$build['openid_login_form']['openid_identifier']['#size'] = $build['user_login_form']['name']['#size'];
$build['content']['openid_login_form'] = drupal_get_form('openid_login_form');
$build['content']['openid_login_form']['openid_identifier']['#size'] = $build['content']['user_login_form']['name']['#size'];
// Put an OpenID link as a first element.
$build['user_links']['#items'] = array(
$build['content']['user_links']['#items'] = array(
l(t('Log in using OpenID'), 'user/login/openid', array(
'attributes' => array(
'title' => t('Log in using OpenID.'),
......@@ -183,10 +183,10 @@ function openid_block_view_user_login_block_alter(&$build, $block) {
'tabindex' => 0,
),
))
) + $build['user_links']['#items'];
) + $build['content']['user_links']['#items'];
// Move links under the openid form.
$build['user_links']['#weight'] = 10;
$build['content']['user_links']['#weight'] = 10;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment