You can not run old code on newer php versions which is why you need to upgrade.
I have removed our code from your post so please refrain from publicly posting code opening on the site thanks.
Now please explain what you mean by it stops dead in its tracks. The upgrade can take awhile. The step you are referring to also can only be ran once so do not run step3 of that upgrade more than once. The move data is step 2 that can be done more than once.
I would suspect maybe a php timeout. The upgrade script sets memory limit to 60M in php and timeout to 0.
Do you have a link to your servers phpinfo so I can make any comments necessary to assist?
The upgrade you are referring to has been around for years. I would definately need info from server logs to diagnose that issue. Basically the upgrade there moves files to the new format and then step 3 renames the filenames which is why you can not run that step more than once.