Re-added fix for bug #66015 and adapted for phpng branch