backported fix for DoctrineBridge bug 4712

(orig commit e97cd61a894ccb1476d5ac4a63efdda1b966acd0)