diff --git a/includes/heartbeatstream.inc b/includes/heartbeatstream.inc
index 184db1c..95161fc 100644
--- a/includes/heartbeatstream.inc
+++ b/includes/heartbeatstream.inc
@@ -600,7 +600,7 @@ abstract class HeartbeatStream {
     $this->query->leftJoin('heartbeat_user_templates', 'hut', ' ha.uid = hut.uid AND ha.message_id = hut.message_id ');
     $this->query->addField('hut', 'status', 'access_status');
     // The user_access field holds the least access known. (NULL = HEARTBEAT_PUBLIC_TO_ALL).
-    $access_expression = "LEAST ( IFNULL ( ha.access, " . HEARTBEAT_PUBLIC_TO_ALL . "), IFNULL ( hut.status, " . HEARTBEAT_PUBLIC_TO_ALL . "))";
+    $access_expression = "LEAST ( COALESCE ( ha.access, " . HEARTBEAT_PUBLIC_TO_ALL . "), COALESCE ( hut.status, " . HEARTBEAT_PUBLIC_TO_ALL . "))";
     $this->query->addExpression($access_expression, 'user_access');
 
     // Exclude unpublished comments.
@@ -979,4 +979,4 @@ abstract class HeartbeatStream {
 
 /**
  * eof().
- */
\ No newline at end of file
+ */
