Fix for backport 9225 stable6

This pull request follows #11217 and it fix #9225 for stable6.

I'll release everything with MIT license.

@blizzz @PVince81