-1

I have only 1 row in my database, when I put this code on my AnnouncementController I have an 500 error page.

public function search(AnnouncesRepository $announcesRepository){

    $announces = $announcesRepository->findAll();

    return $this->render('announces/search.html.twig', ['announces' => $announces]);

}

Logs :

2019-01-22T12:47:53+00:00 [info] Matched route "announcement_search".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::configure".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\ValidateRequestListener::onKernelRequest".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\SessionListener::onKernelRequest".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.request" to listener "Symfony\Bundle\FrameworkBundle\EventListener\ResolveControllerNameSubscriber::onKernelRequest".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.request" to listener "Symfony\Component\HttpKernel\EventListener\LocaleListener::onKernelRequest".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ControllerListener::onKernelController".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\ParamConverterListener::onKernelController".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\HttpCacheListener::onKernelController".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.controller" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::onKernelController".
2019-01-22T12:47:53+00:00 [debug] Notified event "kernel.controller_arguments" to listener "Sensio\Bundle\FrameworkExtraBundle\EventListener\IsGrantedListener::onKernelControllerArguments".
2019-01-22T12:47:53+00:00 [debug] SELECT t0.id AS id_1, t0.society_id AS society_id_2, t0.job AS job_3, t0.city AS city_4, t0.desired_city AS desired_city_5, t0.slug AS slug_6, t0.user_id AS user_id_7, t0.created AS created_8, t0.description AS description_9, t
0.user_id AS user_id_10 FROM announces t0
[Tue Jan 22 13:47:54 2019] 127.0.0.1:56133 [500]: /rechercher - Allowed memory size of 134217728 bytes exhausted (tried to allocate 65028096 bytes) in C:\wamp64\www\permutation\permutation\vendor\twig\twig\lib\Twig\Extension\Debug.php on line 50
2019-01-22T12:47:54+00:00 [critical] Fatal Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65028096 bytes)

It works only when I use find($id) or findOne.

Thanks for help !

Edit :

{% for announce in announces %} {{ dump(announce) }} {% endfor %}

I cleared cache, and yes, increase memory isnt good idea, I have only 1 row ! In my template I tried dump announces too but I have the same error. If I remove the dump, I have any error.

Quentles
  • 9
  • 5
  • https://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted-codeigniter-xml – Jan-Willem de Boer Jan 22 '19 at 13:01
  • 1
    Possible duplicate of [Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)](https://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted-codeigniter-xml) – Jan-Willem de Boer Jan 22 '19 at 13:01
  • 3
    The error in your log is from within twig -> therefor inside your search.html.twig - further can you do a var_dump on the announces to see what is really in there? – wodka Jan 22 '19 at 13:02
  • 2
    increase memory limit isnt good idea, something else is wrong, he has only one row in table – Zeljka Jan 22 '19 at 13:02
  • 1
    Maybe an infinite loop in the template? – Yoshi Jan 22 '19 at 13:03
  • try to clear cache – Zeljka Jan 22 '19 at 13:07
  • Can you share the Twig template? – Nico Haase Jan 22 '19 at 13:32
  • `{% for announce in announces %} {{ dump(announce) }} {% endfor %}` I cleared cache, and yes, increase memory isnt good idea, I have only 1 row ! In my template I tried dump announces too but I have the same error. If I remove the dump, I have any error. – Quentles Jan 22 '19 at 14:04
  • 1
    Run your app in development mode and see what the error message says. Trying to debug an app in production mode is challenging at best. And by the way, using dump in production is a no no as well. – Cerad Jan 22 '19 at 14:49
  • I'm in dev mode but I havn't error message in this case. I have errors for other errors like undefined variables. – Quentles Jan 22 '19 at 14:55
  • Do you have any bigger references in your entity? Maybe you can post that class? – Daniel Jan 22 '19 at 15:43
  • It's working ! It was my ManyToOne relation who generated a lot of objects... – Quentles Jan 22 '19 at 15:51

1 Answers1

0

public function search(AnnouncesRepository $announcesRepository){

ini_set('memory_limit', '-1');

$announces = $announcesRepository->findAll();

return $this->render('announces/search.html.twig', ['announces' => $announces]);

}

or php.ini -> memory_limit = 1024M