MDL-44630: Fixing PHP foreach warnings