PHP upstream patch for https://bugs.php.net/66731