I am having a very annoying issue where certain posts redirect to 404 page when trying to save or publish a post. It only happens to a few posts and did not happen prior to the last few WP updates. I tried disabling all plugins and using different themes with no change. I also tried creating a new post on a different WordPress installation again with no change.
In one post I narrowed it down to one line that if taken out solves the issue, though there is no such line in another post that gives 404 error:
But this causes no issues:
I realise this is a PHP global variable but I don't see why it should cause an issue in a post body as WP should not be interpreting it as code. The PHP variable is part of the code I am displaying within pre tags. Another post that now redirects to 404 page saved just fine when it was first written and so did the post with the GET variable. This means something must have changed in WP.
Can anyone explain why this is happening? It seems like a bug to me.