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
Fix doctrine issues after first request is made. #2042
Conversation
Any chance any one has had a chance to look at this? I don't know if it's the right solution, but it works for us. It would be great to get this bug fixed so we can reliably run our tests without needing to patch codeception. |
If it works for you and tests pass why not to merge then ) |
Fix doctrine issues after first request is made.
Haha ok, I don't claim to know anywhere near enough about the internals of the symfony kernel but if it doesn't break anyone else's tests then I'm happy 😀 |
The solution to clone kernel between requests causes memory leak in functional tests. It can be seen on tests with multiple requests and/or multiple tests in a suite. I had 'out of memory' errors when ran my test. I changed the code of Lib/Connector/Symfony2.php to its previous version and it works now. In relation to [https://github.com//issues/2025]: /*
* Rollback codeception's or any other external transaction(s) and set own
*/
public function prepareDatabase($isTransactional = true)
{
while ($this->em->getConnection()->isTransactionActive()) {
try {
$this->em->getConnection()->rollback();
} catch (\PDOException $e) {
}
}
$em = $this->em;
$reflectedEm = new \ReflectionClass($em);
if ($reflectedEm->hasProperty(' repositories')) {
$property = $reflectedEm->getProperty('repositories');
$property->setAccessible(true);
$property->setValue($em, []);
}
$this->em->clear();
if ($isTransactional) {
$this->em->getConnection()->beginTransaction();
}
} |
Would changing
to
have enabled php to garbage collect when it needs the memory? I will revert the change here to see if our tests run successful (and this was fixed else where) or if the initial problem reappears. |
Just reread you comment, and will look into what you think might be causing the transaction issue |
@vyarmolenko Could you prepare a pull request with your proposed solution? |
Related to #2025
I found this change fixed all the problems I was having when using doctrine to create data in a transaction.
Unsure if it's the right solution, but means my tests now work.