[1.6.x] Fixed #20730 -- Fixed "Programmatically creating permissions" error.

Thanks glarrain for the report.

Backport of 684a606a4e from master