[wp-trac] [WordPress Trac] #24688: Memory exhaustion caused by very many unattached media

WordPress Trac noreply at wordpress.org
Thu Oct 4 02:08:49 UTC 2018


#24688: Memory exhaustion caused by very many unattached media
-------------------------------------+-----------------------------
 Reporter:  andy                     |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Future Release
Component:  Media                    |     Version:  2.5
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+-----------------------------

Comment (by iCaleb):

 Found an issue with the query for retrieving the next attachment link. It
 will always link to the last image attached to the post, not necessarily
 the next one. Turns out, `'orderby' => "menu_order $order, ID $order"`
 will result in `ORDER BY wp_posts.menu_order DESC, wp_posts.ID DESC` no
 matter what $order is (it'll never be ASC). This can be solved by instead
 passing an array into the orderby param as supported since WP 4.0.

 ----

 Next up, `array_pop` was also causing a PHP notice:

 > Notice: Only variables should be passed by reference at wp-
 includes/media.php:2812

 Line 2812 was `'post_parent' => $post->post_parent`. This is solved by
 either passing a single variable into array_pop(), else avoiding using it.
 Since in this case `get_children()` is just either going to return a
 single element array or an empty array, I opted for just accessing the
 first key directly if it exists.

 ----

 Lastly, I did apply the `return "( $where ) AND (` changes mentioned
 above, but it results in a SQL syntax error.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/24688#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list