Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Insight] The EntityManager should not be flushed within a loop - in Bundle/…/BusinessEntitySubscriber.php, line 155 #935

Open
lenybernard opened this issue Jun 1, 2017 · 0 comments

Comments

@lenybernard
Copy link
Contributor

in Bundle/BusinessEntityBundle/EventSubscriber/BusinessEntitySubscriber.php, line 155

Calling flush is a resource intensive operation, especially when a lot of entities are managed by Doctrine. You should pass the entity you want to flush as parameter, or avoid flushing inside a loop.

                        $newSlug = $entity->getSlug();
                        $businessPage->setName($virtualBusinessPage->getName());
                        $businessPage->setSlug($virtualBusinessPage->getSlug());

                        $entityManager->persist($businessPage);
                        $entityManager->flush();
                    }
                }
            }
        }
    }

Posted from SensioLabsInsight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant