Fatal error: Nesting level too deep - recursive dependency? in /var/www/html/web/modules/contrib/burndown/src/Entity/Task.php on line 348

Created on 30 November 2024, about 1 month ago

Problem/Motivation

If you move a task around the swimlane board to many times it creates a memory exhaustion error.

This is the error

Fatal error: Nesting level too deep - recursive dependency? in /var/www/html/web/modules/contrib/burndown/src/Entity/Task.php on line 348

It seems to caused by the following code in the task entity.

web/modules/contrib/burndown/src/Entity/Task.php

  /**
   * Check if this task is on the completed board.
   */
  public function onCompletedBoard() {
    $swimlane = $this->getSwimlane(); <---- This method is what is called.
    $project = $this->getProject();
    $shortcode = $project->getShortcode();
    $completed_lanes = Swimlane::getCompletedSwimlanes($shortcode);
    if ($completed_lanes !== FALSE) {
      foreach ($completed_lanes as $lane) {
        if ($lane == $swimlane) {
          return TRUE;
        }
      }
    }

This is the entity method

  /**
   * {@inheritdoc}
   */
  public function getSwimlane() {
    return $this->get('swimlane')->entity;
  }
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇺Australia purencool

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @purencool
  • 🇨🇦Canada jeremylichtman

    How much memory do you have allocated to PHP? I saw these sorts of issues locally with 256MB when I first started building the module, but anything over 512MB doesn't seem to cause this. The module is a bit of a memory hog though; not sure how to fix that without major changes though.

  • 🇦🇺Australia purencool

    Hi @jeremylichtman

    I have a one gig (1024M) allocation using DDEV.

    As a thought, what field in the swimlane entity does the application need to work? Maybe calling it directly could reduce the memory overhead. Let me know, and I will do some testing for you.

  • 🇨🇦Canada jeremylichtman

    We could switch that to use entity ids, instead of the full entity. Would need to make sure that that is carried through the whole codebase though.

  • 🇨🇦Canada jeremylichtman

    I figured out a different way.

    We already set a value for task->completed when we move the task into that column, so we can just use that value (instead of an expensive check of which col it is currently in).

    Tag 1.0.48 coming in a minute.

  • 🇦🇺Australia purencool

    Okay I will look at the commit and see if I can break it =).

  • 🇦🇺Australia purencool

    It wasn't really working before, but your changes sped it up. However, I managed to break it again. But I may have a solution. What do you think?

      public function onBoard() {
        $swimlane = $this->getSwimlane();
        $project = $this->getProject();
        $shortcode = $project->getShortcode();
        $board_lanes = Swimlane::getBoardSwimlanes($shortcode);
        if ($board_lanes !== FALSE) {
          foreach ($board_lanes as $lane) {
            if ($lane->id() == $swimlane->id()) { <---- I changed this line.
             return TRUE;
            }
          }
        }
    
        return FALSE;
      }
    
  • 🇦🇺Australia purencool

    I changed and tested this locally as well.

      /**
       * Check if task is completed.
       */
      public function isCompleted() {
        // If the task is flagged as done, then just return TRUE.
        $completed = $this->getCompleted();
        if ($completed === TRUE) {
          return TRUE;
        }
    
        // Check if in the final "done" lane of the board.
        $project = $this->getProject();
        $shortcode = $project->getShortcode();
        $swimlane = $this->getSwimlane();
        $done = Swimlane::getDoneSwimlane($shortcode);
        if ($done !== FALSE) {  <------ I added this if statement
          if ($swimlane->id() == $done->id()) {  <------ I changed  this as well
            return TRUE;
          }
        }
    
        // The task is not yet completed.
        return FALSE;
      }
    
  • 🇦🇺Australia purencool

    Also this method I modified.

     /**
       * Check if this task is on the completed board.
       */
      public function onCompletedBoard() {
        $swimlane = $this->getSwimlane();
        $project = $this->getProject();
        $shortcode = $project->getShortcode();
        $completed_lanes = Swimlane::getCompletedSwimlanes($shortcode);
        if ($completed_lanes !== FALSE) {
          foreach ($completed_lanes as $lane) {
            if ($lane->id() == $swimlane->id()) { <---- I change this as well.
              return TRUE;
            }
          }
        }
    
        return FALSE;
      }
    
  • 🇨🇦Canada jeremylichtman

    This is a good point. I fixed the ones you found, plus a couple more that I spotted along the way.

    1.0.49 issued!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024