wp_set_object_terms not updating database without a die()

Before using $cat_ids in the wp_set_object_terms() function, cast all values from the string to a number.

Note from the documentation:

Integers are interpreted as tag IDs. Warning: some functions may return term_ids as strings which will be interpreted as slugs consisting of numeric characters!