In preparations for releasing 5.2.3, I backported the referred patch to branch 5.2 with commit 4676d3d2c1267761ac6405464459b49c809afcbf .
If needed for 5.1, it will be backported before its next release (or someone else can do it right away).
So I am closing this issue, but if still not working as expected, then reopen.