Hi devs
Today we stumbled across, what we think, is a bug. All (at least
almost all) the creation dates are wrong. They are set to the first
occurrence of getDocument() for a specific document and not on first
save(). Usually the difference ist only small (minutes), but there are
cases where the difference are several days.
We suppose that calling getDocument('Test.NotExistingDoc') creates the
document and puts it into the cache with a current timestamp in
creation date. Let's say you work now for an hour before you save the
document, then the creation date would be an hour old even though the
document has just been created.
We always expected the creation date to be the moment of the first
save. Thus we think it's a bug. We came across the problem because we
had someone complaining that a document he created on the 19th was
listed under the ones from the 17th. This could even happen across
users if e.g. there is a link to a not yet existing page. User A
clicks on the link, realizes there is nothing on the page and leaves.
Hours later user B goes to the page and adds content. Now the creation
date of the page would be at an inexplicable time for user B since he
never touched the document until hours after the shown creation date.
We work on 2.7.2 at the moment, but judging by the source code we
think it should be the same in the current version.
To reproduce it create the following script:
#set($newDoc = $xwiki.getDocument('Test.NotExistingDoc'))
$newDoc.getCreationDate()
If you reload several times you see, that the creation date does not
change, even though the document has never been saved. Add a save to
the script:
$newDoc.save()
Now you have a document where creation date and save date of the
version 1.1 do not match.
Should I create a JIRA issue for that? Maybe we could even send you a
git pull request, but you would have to tell us where you want it to
be fixed:
1. In save action. There the creator of the document gets set already.
2. In the store action. We think it would belong there, but are not
sure if this would break something e.g. import or copy
3. Somewhere else
Regards,
Edo