[wp-trac] [WordPress Trac] #24688: Memory exhaustion caused by very many unattached media
WordPress Trac
noreply at wordpress.org
Thu Jul 4 18:20:10 UTC 2013
#24688: Memory exhaustion caused by very many unattached media
--------------------------+-----------------------------
Reporter: andy | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
--------------------------+-----------------------------
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24688>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list