deal with PHP bugs #42098/#54054, closes #1491