Whilst trying to sort an issue with user icons not uploading, I noticed Elgg 1.1 out-of-the-box generates some rather silly errors. So I thought I would fix a couple of them to save filling up my log file while I am getting the This Is Me server working rather better than it did by default.
So, first one I dealt with is a simple problem in mod/messages/start.php which reports an "invalid argument supplied for foreach()" - easy solution, don't try iterating on a collection which is empty!
function count_unread_messages() {
//get the users inbox messages
$num_messages = get_entities_from_metadata("toId", $_SESSION['user']->getGUID(), "object", "messages", 0, 10, 0, "", 0, false);
//set a counter
$counter = 0;
//loop through the inbox and count the number unread
if ($num_messages) { //PNP check it exists first, ppl!
foreach($num_messages as $num){
if($num->readYet == 0)
$counter++;
}
}
return $counter;
}