Make WordPress Core

Opened 5 years ago

Last modified 9 months ago

#23127 new defect (bug)

Media Upload hangs on Crunching on too big image sizes. — at Version 2

Reported by: clubdesign Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.7
Component: Media Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

If the uploaded file is too big for the Max Memory Limit Setting, then the upload is executed, but the image isnt resized to the set image sizes and the frontend gets stuck on "Crunching". I tracked the error down into the core and found out, that the main problem is in the GD library class ( wp-includes/class-wp-image-editor-gd.php ) in the load() function.

Everything works fine before line 91:

$this->image = @imagecreatefromstring( file_get_contents( $this->file ) );

So imagecreatefromstring fails because of a lack of memory. But as a chain reaction everything else fails afterwards. The library is not loaded and sent back, and so on. As a result no id is sent back to the frontend and the Loader hangs.

Maybe there should be any error catching and sending back before this GD function, that the frontend receives any error messages and that the upload is deleted in case of error.

Just my thoughts: As this error is a Fatal one, you can`t use any Exception stuff, cause there will not be any memory left to execute it. Maybe some checking if the id is present before sending the image back to crunching?

Change History (2)

#1 @clubdesign
5 years ago

Another thought on how to prevent this thing from hanging, is to do some basic calculations before to any GD Stuff.

As this article explains there is a rough formula for that: Width x Height x 8 (bits) x 3(channels) / 8 x 1.65 should result in the memory needed for GD. Soooo: Max availiable Memory - Wp needed memory - calc. needed memory. If negative, kick error. Just as a thought. ;)

#2 @SergeyBiryukov
5 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.