Cast term_id as int before using in has_term. Closes #3077 #1999