Check that $route_match is not NULL, such as during drush cron.
When defining $is_internal, check that $route_match is not NULL, such as during drush cron. This prevents excessive InvalidArgumentException errors which can flood the dblog and make it useless.