Don't use anonymous function in MessageModel

the $this variable wasn't allowed in anonymous functions until 5.4, and
using anonymous functions at all until 5.2 - this rewrites the function
to not use array_filter with an anonymous function

Fixes #2143