2.5 upgrade

Code borrowed from my kick ass upgrade shell - might be worth adding this to the core one.

Refs https://github.com/cakephp/cakephp/issues/2597