- if (count($msg->entities) == 0) {
- $entity[] = $msg->entity_id;
- } else {
- $entity = $msg->findDisplayEntity($entity, $alt_order, $strict);
+ if ( ! is_null($msg) ) {
+ if (count($msg->entities) == 0) {
+ $entity[] = $msg->entity_id;
+ } else {
+ $entity = $msg->findDisplayEntity($entity, $alt_order, $strict);
+ }
+ $found = true;