I know, it sucks! And I still don’t get exactly why this happens and how I can preven it.
Every time I introduce a new function in the main file (includes/class-caos.php) for some reason, during updating, this file comes last, but it’s already executing the rest of the code — or something. Also, it seems to only happen on servers running some sort of PHP caching mechanism, like Opcache or Varnish.
Are you running either of those? If so, flushing those caches should resolve the issue.
So, flushing those caches before the update should prevent the issue. Unfortunately I’ve no clue what I can do about that.
Wait, I just noticed something in your stack trace: I run an update of the JS files after the update of the plugin is done, this function is called update_after_update. Maybe the timing there isn’t correct and the new code is executed too soon? I’ll look into this, thanks for sharing!
