[wp-trac] [WordPress Trac] #39768: Incorrect image returned with attachment_url_to_postid()

WordPress Trac noreply at wordpress.org
Sun Dec 22 17:17:36 UTC 2019


#39768: Incorrect image returned with attachment_url_to_postid()
--------------------------+---------------------
 Reporter:  ben.greeley   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  5.4
Component:  Media         |     Version:  4.7.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+---------------------

Comment (by SergeyBiryukov):

 Replying to [comment:6 SergeyBiryukov]:
 > I'm up for updating the query in `attachment_url_to_postid()` to be
 case-sensitive and handle already existing images, if that does not reduce
 performance.

 On a site with ~32000 attachments, seeing no noticeable difference in
 performance

 {{{
 SELECT post_id FROM wp_postmeta WHERE meta_key = '_wp_attached_file' AND
 meta_value = '2009/03/myimage.jpg'
 Query took 0.0292 seconds.

 SELECT post_id FROM wp_postmeta WHERE meta_key = '_wp_attached_file' AND
 BINARY meta_value = '2009/03/myimage.jpg'
 Query took 0.0294 seconds
 }}}

 Both queries use the index:

 ||id||select_type||table||type||possible_keys||key||key_len||ref||rows||Extra||
 ||1||SIMPLE||wp_postmeta||ref||meta_key||meta_key||768||const||30557||Using
 index condition; Using where||

 Should be good to go.

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


More information about the wp-trac mailing list