Some users might not like that they lose the ability to adjust their nation based on the new government before turn change. Especially in the single-player where the old behavior causes no problems at all. Should we make it user choice which model they want (server setting)?
Simple patch attached. The relatively high risk of introducing bugs with this is mainly due to side-effects of government_change() - it might not be a good idea to do those things in the new location in the middle of end-phase handling.
From my comment in #41813:
"
I think that for this the engine should enforce some rules, and not leave it to ruleset to plug every possible exploit. This could work similar to multiplier changes that can be chosen during the turn freely, but are activated only at turn change (it has two variables; one that is the really active value, and second that tells what value user wants to activate in the next turn change)"