(bug 47023) Add array type check before being used in foreach loop

Change-Id: I28e7f1a52b337ee0a4b012ad31e8054c8f6798ed