Only check if is_robots() if $wp_query is set.
Move DONOTCACHEPAGE to a separate method.