[generate:entity:content] Listing Entities Instead of Types in Permissions
[generate:entity:content] Listing Entities Instead of Types in Permissions
Problem/Motivation
In generating the permissions we are gathering all entities instead of entitytypes foreach (Sample::loadMultiple() as $type) {
Solution
Replace "Entity" references with "EntityType" references
use Drupal\compare\Entity\Sample; use Drupal\compare\Entity\SampleType;
foreach (Sample::loadMultiple() as $type) {
foreach (SampleType::loadMultiple() as $type) {
- @param \Drupal\compare\Entity\Sample $type
- @param \Drupal\compare\Entity\SampleType $type
protected function buildPermissions(sample $type) { protected function buildPermissions(sampleType $type) {
This is pretty serious - it may not cause problems immediately, but it can blow up months later in production. This issue caused our site to get slower and slower over time, then finally timeout, once we hit about 6,000 entities. Thankfully we caught it during development.
This appears to be a duplicate of issue 4216.
I applied the changes listed in the 4216 commit (which appears to be the same as listed here) and it resolve the issue for me.