Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#22438 closed defect (bug) (fixed)

wp_generate_attachment_metadata() should not call WP_Image_Editor if there's nothing to resize

Reported by: mdawaffe Owned by: nacin
Priority: normal Milestone: 3.5
Component: Media Version: 3.5
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

wp_generate_attachment_metadata() calls WP_Image_Editor::multi_resize() to create the intermediate sizes of the image.

If there are no sizes to create, WP_Image_Editor::get_instance() should not be called. It will not be used for anything and is a waste of resources.

If it is called, and the image is very large, a needless Out of Memory Fatal Error can result.

Patch attached.

Attachments (1)

22438.diff (763 bytes ) - added by mdawaffe 14 years ago.

Download all attachments as: .zip

Change History (4)

@mdawaffe
14 years ago

#1 @mdawaffe
14 years ago

I put in the else condition to set $metadata['sizes'] = array() since that's what the current behavior in trunk is: ::multi_resize() returns an empty array if $sizes is empty.

In 3.4, $metadata['sizes'] would have been left unset.

#2 @SergeyBiryukov
14 years ago

  • Component GeneralMedia
  • Milestone Awaiting Review3.5

#3 @nacin
14 years ago

  • Owner set to nacin
  • Resolutionfixed
  • Status newclosed

In 22571:

wp_generate_attachment_metadata() should not call WP_Image_Editor if there's nothing to resize. props mdawaffe. fixes #22438.

Note: See TracTickets for help on using tickets.