Back-patch of commits 628cbb50 and c6aae304. This has been broken since 7.3, so back-patch to all supported branches.