Hi! I'm typing on my phone at the airport so apologies for the brevity and lack of quoting from previous messages. I will summarize everything in detail with commit references to clear up any confusion in the next couple of days.
I believe that by applying the patch below to the 5.4 and 5.5 branches as they exist currently everything is solved: https://bugs.php.net/patch-display.php?bug=41631&patch=bug41631.patch&revision=1411139621 However I ran out of time to perform the necessary due diligence and add test cases before traveling. In any case I will find time to summarize what needs to happen on-list as soon as I am able.