Fatal error: Allowed memory : ->create('Pdf')->buildFromTemplate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • item
    Active Community Member
    • Mar 2017
    • 1476

    Fatal error: Allowed memory : ->create('Pdf')->buildFromTemplate

    Hello Team, Maximus
    still 5.9.4 ..
    i have a issue with generate pdf from Jobs.

    By default "Htmlizer" get data from related record.. in my case, it's impossible ! one contact can have million "care" record !

    It's not possible to set as "param" : a array of related to load or not ? for developper only

    Regards


    PHP Code:
    <?php
    protected function getDataFromEntity(Entity $entity, $skipLinks = false, $level = 0, ?string $template = null)
    {
    $skipLinks = true;  // <- i have put this and i can create PDF
    ?>

    PHP Code:
    <?php
    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 16384 bytes) in /application/Espo/ORM/DB/Mapper.php on line 220
    
    Call Stack:
    16839984884.2149 395224 1. {main}() /command.php:0
    16839984884.2149 5484752 2. Espo\Core\Application->runCommand() /command.php:39
    16839984884.2149 11094736 3. Espo\Core\Console\CommandManager->run() /application/Espo/Core/Application.php:225
    16839984884.2149 11103400 4. Espo\Core\Console\Commands\RunJob->run() /application/Espo/Core/Console/CommandManager.php:76
    16839984884.2149 11301520 5. Espo\Core\CronManager->runJob() /application/Espo/Core/Console/Commands/RunJob.php:60
    16839984884.2149 11301520 6. Espo\Core\CronManager->runJobByName() /application/Espo/Core/CronManager.php:309
    16839984884.2149 11407448 7. Espo\Custom\Jobs\PaymentJobs->run() /application/Espo/Core/CronManager.php:399
    16839984884.2149 18404384 8. Espo\Services\Pdf->buildFromTemplate() /custom/Espo/Custom/Jobs/PaymentJobs.php:43
    16839984884.2149 27234792 9. Espo\Services\Pdf->printEntity() /application/Espo/Services/Pdf.php:289
    16839984884.2149 29575312 10. Espo\Core\Htmlizer\Htmlizer->render() /application/Espo/Services/Pdf.php:112
    16839984884.2149 30358888 11. Espo\Core\Htmlizer\Htmlizer->getDataFromEntity() /application/Espo/Core/Htmlizer/Htmlizer.php:562
    16839984884.2149 266612400 12. Espo\Core\Htmlizer\Htmlizer->getDataFromEntity() /application/Espo/Core/Htmlizer/Htmlizer.php:163
    16839984884.2149 266672328 13. Espo\Custom\Entities\Care->get() /application/Espo/Core/Htmlizer/Htmlizer.php:264
    16839984884.2149 266672368 14. Espo\Custom\Repositories\Care->findRelated() /application/Espo/ORM/Entity.php:144
    16839984884.2149 266672400 15. Espo\ORM\DB\MysqlMapper->selectRelated() /application/Espo/ORM/Repositories/RDB.php:268
    16839984884.2149 266681976 16. PDO->query() /application/Espo/ORM/DB/Mapper.php:220
    ?>
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​
  • Maximus
    Senior Member
    • Nov 2018
    • 2731

    #2
    Hi there,
    If you don't specify in your PDF Template {{#each linkName}}, then it should omit the related record loading.
    I believe here is the check in /application/Espo/Core/Htmlizer/Htmlizer.php
    PHP Code:
    mb_stripos($template, '{{#each '.$relation.'}}') !== false 
    

    Comment

    • item
      Active Community Member
      • Mar 2017
      • 1476

      #3
      Hello Maximus,

      This is a blank template with just {{name}} .. by default as i see in these file, he load all relation.

      Yes this is in these file.. as i know Yuri modify pdf actually .. maybe
      and i have see a value "limit" = 100 by default..

      Thanks
      If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

      Comment

      • item
        Active Community Member
        • Mar 2017
        • 1476

        #4
        Hello Maximus

        just say : i have overide Services/Pdf.php and make my own buildFromTemplateSkipLinks( ..... , $skipLinks = true) and render(.. , $skipLinks = true)

        I think there are somewhere it loop in htmlizer.php without these parameter.

        Regards



        If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

        Comment

        Working...