Fix an error in UpgradeHandler for fresh installs.
Fix another issue when tables do not exist (runonce.php called via install.php).
Merge branch 'tng' into rework-sorting