ornicar/OrnicarMessageBundle — Issue #26: threadMetaData.lastMessageDate should be null while not
Author: KailZhang
Created: 2011-10-18 14:49:02+00:00
State: open

If you just create a new thread, you'll see this one in your inbox. This is not intentional.

After a little dig into source code, EntityManager/ThreadManager::findParticipantInboxThreads does select threads that have at least one message written by another participant by 'tm.lastMessageDate IS NOT NULL', while lastMessageDate is NOT NULL even was just created. It's 1970-01-01 08:00:00.

This is caused by, in doDatesOfLastMessageWrittenByOtherParticipant, timestamp is default set to 0, which will be set to lastMessageAt. So you can fix this issue by wrap
$date = new \DateTime();
$date->setTimestamp($timestamp);
$meta->setLastMessageDate($date);
in $timestamp > 0 condition.