Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions forum.module
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ function forum_forum_load($tid = NULL) {
->fetchObject();

// Merge in the "Last Post" information.
$last_post = new stdClass();
$last_post = new Node();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$last_post = new Node();
$last_post = entity_create('node', array());

I think we standardizing in core to use entity_create() instead of creating entities with new X.

if (!empty($topic->last_comment_timestamp)) {
$last_post->created = $topic->last_comment_timestamp;
$last_post->name = $topic->last_comment_name;
Expand Down Expand Up @@ -878,7 +878,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
);

$order = _forum_get_topic_order($sortby);
for ($i = 0; $i < count($forum_topic_list_header); $i++) {
for ($i = 1; $i < count($forum_topic_list_header); $i++) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of another PR which was merged so this no conflicts.

if ($forum_topic_list_header[$i]['field'] == $order['field']) {
$forum_topic_list_header[$i]['sort'] = $order['sort'];
}
Expand Down Expand Up @@ -927,15 +927,17 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
->orderByHeader($forum_topic_list_header)
->condition('n.nid', $nids);

$result = $query->execute();
$result = $query->execute()->fetchAllAssoc('nid', PDO::FETCH_ASSOC);
}
else {
$result = array();
}

$topics = array();
$first_new_found = FALSE;
foreach ($result as $topic) {
foreach ($result as $topic_result) {
$topic = new Node($topic_result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$topic = new Node($topic_result);
$topic = new entity_create('node', $topic_result);


if ($user->uid) {
// A forum is new if the topic is new, or if there are new comments since
// the user's last visit.
Expand All @@ -962,12 +964,13 @@ function forum_get_topics($tid, $sortby, $forum_per_page) {
}

if ($topic->comment_count > 0) {
$last_reply = new stdClass();
$last_reply = new Node();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$last_reply = new Node();
$last_reply = new entity_create('node', array());

$last_reply->created = $topic->last_comment_timestamp;
$last_reply->name = $topic->last_comment_name;
$last_reply->uid = $topic->last_comment_uid;
$topic->last_reply = $last_reply;
}

$topics[] = $topic;
}

Expand Down Expand Up @@ -1160,7 +1163,10 @@ function template_preprocess_forum_topic_list(&$variables) {
$variables['topics'][$id]->new_url = '';
if ($topic->new_replies) {
$variables['topics'][$id]->new_text = format_plural($topic->new_replies, '1 new', '@count new');
$variables['topics'][$id]->new_url = url("node/$topic->nid", array('query' => comment_new_page_count($topic->comment_count, $topic->new_replies, $topic), 'fragment' => 'new'));

$count = comment_new_page_count($topic->comment_count, $topic->new_replies, $topic);
$options = array('query' => $count, 'fragment' => 'new');
$variables['topics'][$id]->new_url = url("node/$topic->nid", $options);
}

}
Expand Down