Fixes #17806: Upgrade your installation consistently failing

This error was due to new php code creating a new token before user gets the upgrade page.
This caused the upgrade to fail due to finding a token that doesn't deserialize using php
unserialize() method.

I've applied two fixes:
- Check unserialize() and json_decode() before failing.
- Direct to admin/install.php after login if db is out of date.

We can still do some improvements in this space, but this fixed the blocking issue for now.