Correct invalid foreach error when no results are found. #1446