Download & Extend

Wrong formatted node date in full mode

Project:Recent Blocks
Version:4.7.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

There's a bug in this line (function _recent_blocks_block):

($show['node date'] ? '<br />'. t('%time ago', array('%time' => format_interval(time() - $node->$s['mode_full_sort']))) : '') .

Note that mode_full_sort may not point to the node changed column. Here's how IMO that line should look:

($show['node date'] ? '<br />'. t('%time ago', array('%time' => format_interval(time() - $node->changed))) : '') .

Comments

#1

Title:Wrong node formatted in date in full mode» Wrong formatted node date in full mode

Sorry, fixing the title. How could I wrote that?

#2

Status:needs review» closed (works as designed)

Hi.

Please note that sorting method is configurable and $s['mode_full_sort'] tells us by which property we should sort.

#3

But this is not about the "Sort by", but about the date displayed when "Show what?" is set to 'node date'.

...or is it that "Show what?" refers to the date selected in the "Sort by" field? If so, this is not clear in the settings panel description. I seemed to me that 'node date' was related to the $node->changed data.

I'm afraid to change the status of the issue.

#4

Status:closed (works as designed)» needs review

If "Sort what" refers to "Sort by", then one thing is wrong, the "created" column is missing in the query used in _recent_blocks_block() for full mode:

    $sql = "SELECT n.nid, n.title, n.uid, n.changed, l.last_comment_timestamp, GREATEST(n.changed, l.last_comment_timestamp) AS last_change, l.comment_count".
            " FROM {node} n, {node_comment_statistics} l".
            " WHERE n.nid = l.nid AND $common_where AND $wow_comments".
            " ORDER BY $s[mode_full_sort] DESC";

With the created column:

    $sql = "SELECT n.nid, n.title, n.uid, n.created, n.changed, l.last_comment_timestamp, GREATEST(n.changed, l.last_comment_timestamp) AS last_change, l.comment_count".
            " FROM {node} n, {node_comment_statistics} l".
            " WHERE n.nid = l.nid AND $common_where AND $wow_comments".
            " ORDER BY $s[mode_full_sort] DESC";

#5

Status:needs review» fixed

You're right.

I've changed it so it displays node 'created' date if "sort by" is set to created, or 'changed' in all other cases.

But I think it'd be nice to be able to display GREATEST(last post, changed) even if there are no comments (currently not possibile)...

#6

Status:fixed» closed (fixed)
nobody click here