Moving drupal_flush_all_caches to inside conditional statement