WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 7 months ago

#24688 new defect (bug)

Memory exhaustion caused by very many unattached media

Reported by: andy Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.5
Component: Media Keywords: has-patch 3.7-early
Focuses: Cc:

Description

A blog with over 30,000 unattached images was exhausting available memory on unattached attachment pages. The exhaustion occurred in previous_image_link() -> adjacent_image_link() -> get_children() due to the large number of rows selected with post_parent=0.

This is not the only place where get_posts() might be called with post_parent=0. A similar query appears in twentythirteen_the_attached_image() but the effect is wisely mitigated by fields=ids. Earlier, twentyten/loop-attachment.php called get_children() with post_parent=0 on unattached image pages which is horribly inefficient when there are many unattached images.

Attached patch depends on #24687. The change to adjacent_image_link() creates a MySQL query which selects only the desired row. This fixes the memory exhaustion error on the blog with 30,000 unattached images. The once-only filters would be unnecessary if WP_Query accepted arbitrary extra WHERE strings.

Attachments (1)

24688.diff (2.4 KB) - added by andy 10 months ago.

Download all attachments as: .zip

Change History (6)

andy10 months ago

comment:1 SergeyBiryukov10 months ago

  • Component changed from General to Media

Related: #23044

comment:2 nacin9 months ago

  • Keywords has-patch 3.7-early added
  • Milestone changed from Awaiting Review to Future Release

comment:3 SergeyBiryukov9 months ago

  • Version changed from trunk to 2.5

Related: [7222]

comment:4 wonderboymusic9 months ago

  • Milestone changed from Future Release to 3.7

these are all marked 3.7-early

comment:5 ocean907 months ago

  • Milestone changed from 3.7 to Future Release

Punting due to lack of testing.

Note: See TracTickets for help on using tickets.