Fix CRM-13113. Do not try to foreach() an empty array.