drupal-console icon indicating copy to clipboard operation
drupal-console copied to clipboard

[generate:entity:content] Listing Entities Instead of Types in Permissions

Open kenton-r opened this issue 6 years ago • 2 comments

[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) {

kenton-r avatar Jan 15 '20 07:01 kenton-r

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.

les-lim avatar Sep 27 '20 15:09 les-lim

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.

severingoodwin avatar Jan 13 '21 16:01 severingoodwin