Commit fbb36134 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use consistent ordering in plans, blog blocks



If there are multiple blog posts or tasks with exactly the same
creation or completion time, the same blog post can appear on two
different pages of results, because the the order by part of the query
is not restrictive enough to produce an unambiguous order.

Change-Id: I59a7110b49e92af1a05dba37379707ea9fc225ef
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent a9c42fc6
...@@ -66,7 +66,7 @@ class PluginBlocktypeRecentposts extends PluginBlocktype { ...@@ -66,7 +66,7 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
AND a.parent IN ( ' . $artefactids . ' ) AND a.parent IN ( ' . $artefactids . ' )
AND a.owner = (SELECT "owner" from {view} WHERE id = ?) AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
AND ' . $before . ' AND ' . $before . '
ORDER BY a.ctime DESC ORDER BY a.ctime DESC, a.id DESC
LIMIT ' . $limit, array($instance->get('view')))) { LIMIT ' . $limit, array($instance->get('view')))) {
$mostrecent = array(); $mostrecent = array();
} }
......
...@@ -65,7 +65,7 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype { ...@@ -65,7 +65,7 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
WHERE a.artefacttype = \'blogpost\' WHERE a.artefacttype = \'blogpost\'
AND a.owner = (SELECT "owner" from {view} WHERE id = ?) AND a.owner = (SELECT "owner" from {view} WHERE id = ?)
AND at.tag = ? AND at.tag = ?
ORDER BY a.ctime DESC ORDER BY a.ctime DESC, a.id DESC
LIMIT ?'; LIMIT ?';
$results = get_records_sql_array($sql, array($view, $tagselect, $limit)); $results = get_records_sql_array($sql, array($view, $tagselect, $limit));
......
...@@ -693,7 +693,7 @@ class ArtefactTypeBlogPost extends ArtefactType { ...@@ -693,7 +693,7 @@ class ArtefactTypeBlogPost extends ArtefactType {
a.id, a.title, a.description, a.author, a.authorname, ' . a.id, a.title, a.description, a.author, a.authorname, ' .
db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ', db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
a.locked, bp.published, a.allowcomments ' . $from . ' a.locked, bp.published, a.allowcomments ' . $from . '
ORDER BY bp.published ASC, a.ctime DESC', ORDER BY bp.published ASC, a.ctime DESC, a.id DESC',
array($id), array($id),
$offset, $limit $offset, $limit
); );
......
...@@ -533,7 +533,7 @@ class ArtefactTypeTask extends ArtefactType { ...@@ -533,7 +533,7 @@ class ArtefactTypeTask extends ArtefactType {
FROM {artefact} a FROM {artefact} a
JOIN {artefact_plans_task} at ON at.artefact = a.id JOIN {artefact_plans_task} at ON at.artefact = a.id
WHERE a.artefacttype = 'task' AND a.parent = ? WHERE a.artefacttype = 'task' AND a.parent = ?
ORDER BY at.completiondate ASC", array($plan), $offset, $limit)) ORDER BY at.completiondate ASC, a.id", array($plan), $offset, $limit))
|| ($results = array()); || ($results = array());
// format the date and setup completed for display if task is incomplete // format the date and setup completed for display if task is incomplete
......
Supports Markdown
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