PHP fatal recursion error when saving comments

Created on 17 June 2025, 16 days ago

Problem/Motivation

Since https://www.drupal.org/project/minikanban/issues/3529811 🐛 Attachments on tasks are overwritten Active was merged, if a task has more than 1 attachment a php fatal recursion error occurs when saving the task.

Steps to reproduce

// Load files that already exist.
$file = \Drupal\file\Entity\File::load(1);
$file2 = \Drupal\file\Entity\File::load(2);

// Create a new task.
$mytask = \Drupal\minikanban\Entity\Task::create();

// Add the file to the task and save.
$mytask->get('attachments')->appendItem($file);
$mytask->get('attachments')->appendItem($file2);

// Should save, but generates a php fatal.
$mytask->save();

Proposed resolution

The above is caused due to the array_unique call in Task::preSave (line 166), as array_unique converts objects to strings to do the comparison.

Doing a uniqueness check on the file IDs rather than the file entities themselves should resolve this, but this would require ensuring that the files have already been saved before adding them to the attachments collection and I'm unsure if this is a safe assumption.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom jeremyskinner

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024