Avoid notices: Before checking if retval is an array, check if it is defined.