Media library Fatal error: Allowed memory size exhausted

Created on 20 April 2022, over 2 years ago
Updated 18 September 2024, 3 months ago

Problem/Motivation

Hi, I made a custom Gutenberg block that contains image upload functionality. The custom block requires the MediaUpload from wp.blockEditor, and on fresh copy of Drupal with few images are working well, I can upload images, I can attache images without any problem.

The problem started when I move the custom block into a website where is hundreds of images, the at this point it stop working. The media library popup is empty and I get error in the console:

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

When we investigate the source of the problem we find out that media library using this API - /editor/media/search/image/*
The API looking for the all images in the media library and when we go to that link directly it has an error:

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 20480 bytes) in web/core/lib/Drupal/Core/Entity/ContentEntityBase.php on line 746

I assume this is happens because of too many request this API do, and our server does not have enough memory allocated for the process.

Proposed resolution

I was wonder if there is a way to set the image search for the specific category in the media library, or is there is any other solutions you can suggest instead let the media library search for all of the images in the media library?

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇬🇧United Kingdom Artiom Sobolev

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024