This issue has been created
There are 5 updates.
 
 
XWiki Platform / cid:jira-generated-image-avatar-4450565e-4006-4a88-b11b-79133d1edba4 XWIKI-23506 Open

Comments are ordered by date of type String instead of type date

 
View issue   ·   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-081df07a-1767-40af-96bf-3086c0048379 Florian Véron created this issue on 04/Sep/25 09:52
 
Summary: Comments are ordered by date of type String instead of type date
Issue Type: cid:jira-generated-image-avatar-4450565e-4006-4a88-b11b-79133d1edba4 Bug
Affects Versions: 17.4.2, 17.4.4
Assignee: Unassigned
Created: 04/Sep/25 09:52
Priority: cid:jira-generated-image-static-major-b5cecdeb-40ea-40b9-a6d7-38d5f265bb29 Major
Reporter: Florian Véron
Description:

The issue come from `commentsinline.vm` and a part of the code introduced by XWIKI-22978 .

  • Cause :
## Build a map on the form Date -> List<Comment object>
## We also keep the set of keys when we have multiple comments at same date just to order them later (it should be a
## very rare case but let's ensure we keep a deterministic order)
#set ($commentMap = $collectiontool.getSortedMap())
#set ($keysWithMultipleComments = $collectiontool.getSet())
#foreach ($comment in $comments)
  #set ($key = $comment.date)
  #if ($commentMap.containsKey($key))
    #set ($discard = $commentMap.get($key).add($comment))
    #set ($discard = $keysWithMultipleComments.add($key))
  #else
    #set ($discard = $commentMap.put($key, [$comment]))
  #end
#end

The list is ordered by key and the line `#set ($key = $comment.date)` will set the list to be ordered by date.
The issue here is `$comment.data` get a date as String (example : “23/11/2017 14:25:44”), and then the sortedMap see a String and will order as text.

  • How to reproduce

1. Create multiple comments on the same document
2. Update the last comment date to be a day be a day before a previous comment, but also add one to the year, so the comment is still the last one (workd also with month)
Result : The modified comment, is ordered by the day and become the first comment.

Expected : As the year is higher, it must be the last one.

 
 

5 updates

 
cid:jira-generated-image-avatar-081df07a-1767-40af-96bf-3086c0048379 Changes by Florian Véron on 04/Sep/25 09:53
 
Assignee: Simon Urli
 
cid:jira-generated-image-avatar-92526e0c-36c8-4144-987d-8a96516cfa94 Changes by Simon Urli on 04/Sep/25 09:58
 
Version: 16.10.11
Priority: Major Blocker
Component: Web - Templates & Resources
Labels: regression