Fixes #8416 - Fix Puppet classes form n+1 queries