From ada6432e5e8844e9d0c8ce42e7ee5d88c9224ef9 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Sat, 29 May 2010 07:53:44 +0000
Subject: [PATCH] - Patch #809558 by mr.baileys: node_title_list() didn't
 return renderable array for block content.

---
 modules/blog/blog.module             |  9 +++++++--
 modules/forum/forum.module           |  4 ++--
 modules/node/node.module             |  8 ++++----
 modules/statistics/statistics.module | 11 +++++++----
 4 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index b728e439a245..fd20351b5bc9 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -241,9 +241,14 @@ function blog_block_view($delta = '') {
       ->execute();
 
     if ($node_title_list = node_title_list($result)) {
-      $block['content'] = $node_title_list;
-      $block['content'] .= theme('more_link', array('url' => url('blog'), 'title' => t('Read the latest blog entries.')));
       $block['subject'] = t('Recent blog posts');
+      $block['content']['blog_list'] = $node_title_list;
+      $block['content']['blog_more'] = array(
+        '#theme' => 'more_link',
+        '#url' => url('blog'),
+        '#title' => t('Read the latest blog entries.'),
+      );
+
       return $block;
     }
   }
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index ea7f77f07e5c..9984787e6d38 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -699,8 +699,8 @@ function forum_block_view($delta = '') {
 function forum_block_view_pre_render($elements) {
   $result = $elements['#query']->execute();
   if ($node_title_list = node_title_list($result)) {
-    $elements['forum_list'] = array('#markup' => $node_title_list);
-    $elements['forum_more'] = array('#markup' => theme('more_link', array('url' => url('forum'), 'title' => t('Read the latest forum topics.'))));
+    $elements['forum_list'] = $node_title_list;
+    $elements['forum_more'] = array('#theme' => 'more_link', '#url' => url('forum'), '#title' => t('Read the latest forum topics.'));
   }
   return $elements;
 }
diff --git a/modules/node/node.module b/modules/node/node.module
index b942e2e27fe3..12f1017baf67 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -271,7 +271,7 @@ function node_admin_paths() {
 }
 
 /**
- * Gather a listing of links to nodes.
+ * Gathers a listing of links to nodes.
  *
  * @param $result
  *   A DB result object from a query to fetch node entities. If your query
@@ -282,8 +282,8 @@ function node_admin_paths() {
  *   A heading for the resulting list.
  *
  * @return
- *   An HTML list suitable as content for a block, or FALSE if no result can
- *   fetch from DB result object.
+ *   A renderable array containing a list of linked node titles fetched from
+ *   $result, or FALSE if there are no rows in $result.
  */
 function node_title_list($result, $title = NULL) {
   $items = array();
@@ -293,7 +293,7 @@ function node_title_list($result, $title = NULL) {
     $num_rows = TRUE;
   }
 
-  return $num_rows ? theme('item_list__node', array('items' => $items, 'title' => $title)) : FALSE;
+  return $num_rows ? array('#theme' => 'item_list__node', '#items' => $items, '#title' => $title) : FALSE;
 }
 
 /**
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 983dba45bd7e..859ca1e4e1b7 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -350,21 +350,24 @@ function statistics_block_view($delta = '') {
 
     $daytop = variable_get('statistics_block_top_day_num', 0);
     if ($daytop && ($result = statistics_title_list('daycount', $daytop)) && ($node_title_list = node_title_list($result, t("Today's:")))) {
-      $content[] = $node_title_list;
+      $content['top_day'] = $node_title_list;
+      $content['top_day']['#suffix'] = '<br />';
     }
 
     $alltimetop = variable_get('statistics_block_top_all_num', 0);
     if ($alltimetop && ($result = statistics_title_list('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
-      $content[] = $node_title_list;
+      $content['top_all'] = $node_title_list;
+      $content['top_all']['#suffix'] = '<br />';
     }
 
     $lasttop = variable_get('statistics_block_top_last_num', 0);
     if ($lasttop && ($result = statistics_title_list('timestamp', $lasttop)) && ($node_title_list = node_title_list($result, t('Last viewed:')))) {
-      $content[] = $node_title_list;
+      $content['top_last'] = $node_title_list;
+      $content['top_last']['#suffix'] = '<br />';
     }
 
     if (count($content)) {
-      $block['content'] = implode('<br />', $content);
+      $block['content'] = $content;
       $block['subject'] = t('Popular content');
       return $block;
     }
-- 
GitLab