Use oa_core_get_parents() rather than directly accessing the field (and made a minor change to prevent crashing if the space doesn't actually exist).