Cannot remove or edit referenced entities when used in layout builder

Created on 4 April 2023, about 1 year ago

Problem

We are using Entity browser to reference entities inside a layout builder block.
This is working out great for adding entities. However, if we want to remove an entity from the field the following error is thrown:

An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size that this server supports.

The error message is describing the wrong problem since i am not uploading anything, nor is it exceeding the maximum file size.

I found https://drupal.stackexchange.com/questions/250078/ajax-submission-leads-... which explains the same problem i'm facing.

The error was triggered from core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php

if ($exception instanceof BrokenPostRequestException && $request->query->has(FormBuilderInterface::AJAX_FORM_REQUEST)) {
        $this->messenger->addError($this->t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', ['@size' => $this->formatSize($exception->getSize())]));
      $response = new AjaxResponse(NULL, 200);
      $status_messages = ['#type' => 'status_messages'];
      $response->addCommand(new PrependCommand(NULL, $status_messages));
      $event->allowCustomResponseCode();
      $event->setResponse($response);
      return;
}

The error triggered if the BrokenPostRequestException exception is thrown.

Now if we got to core/lib/Drupal/Core/Form/FormBuilder.php we find that this exception is thrown if the post request is bigger than what is allowed by the server and also if the request doesn't carry the form id.

if ($ajax_form_request && !$request->request->has('form_id')) {
  throw new BrokenPostRequestException($this->getFileUploadMaxSize());
}
πŸ› Bug report
Status

Closed: duplicate

Version

2.9

Component

Core API

Created by

πŸ‡§πŸ‡ͺBelgium svdhout

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

Comments & Activities

Production build 0.69.0 2024