Joomla 5.4.8 and 6.1.3 Break the Template Manager

Joomla 5.4.8 and 6.1.3 break four Template Manager actions with a Snooping out of bounds error. Creating component and plugin overrides, and creating and deleting template folders, all fail. Here is the cause, the manual fix, and how to reverse it.