From 5c1869b6128d645588d482348ea105b6ee657a48 Mon Sep 17 00:00:00 2001 From: webchick Date: Mon, 7 Apr 2014 08:00:03 -0700 Subject: [PATCH] Issue #2228941 by larowlan, andrei.dincu | Cottser: PHP notice displayed for forum blocks when there are no forum topics. --- .../forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php | 1 + .../forum/lib/Drupal/forum/Tests/ForumBlockTest.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php b/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php index 6b760a95489..d7dfc31ee95 100644 --- a/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php +++ b/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php @@ -21,6 +21,7 @@ abstract class ForumBlockBase extends BlockBase { */ public function build() { $result = $this->buildForumQuery()->execute(); + $elements = array(); if ($node_title_list = node_title_list($result)) { $elements['forum_list'] = $node_title_list; $elements['forum_more'] = array( diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php index 3799288956d..1295c822aaf 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumBlockTest.php @@ -55,13 +55,14 @@ class ForumBlockTest extends WebTestBase { public function testNewForumTopicsBlock() { $this->drupalLogin($this->adminUser); - // Create 5 forum topics. - $topics = $this->createForumTopics(); - // Enable the new forum topics block. $block = $this->drupalPlaceBlock('forum_new_block'); $this->drupalGet(''); + // Create 5 forum topics. + $topics = $this->createForumTopics(); + + $this->assertLink(t('More'), 0, 'New forum topics block has a "more"-link.'); $this->assertLinkByHref('forum', 0, 'New forum topics block has a "more"-link.');