#563106 by quicksketch, scor, andypost, ctmattice1, catch, yched, adrian: Fix critical upgrade path bugs from Drupal 6 to Drupal 7