[wp-trac] [WordPress Trac] #41816: attachment_url_to_postid() should find post_id for URLs of intermediate size images

WordPress Trac noreply at wordpress.org
Wed Sep 6 15:58:16 UTC 2017


#41816: attachment_url_to_postid() should find post_id for URLs of intermediate
size images
-------------------------------------------------+-------------------------
 Reporter:  pbiron                               |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Media                                |  Review
 Severity:  normal                               |     Version:  trunk
 Keywords:  has-patch dev-feedback 2nd-opinion   |  Resolution:
  has-unit-tests                                 |     Focuses:
-------------------------------------------------+-------------------------
Changes (by pbiron):

 * keywords:  has-patch dev-feedback 2nd-opinion => has-patch dev-feedback
     2nd-opinion has-unit-tests


Comment:

 In addition to adding new unit tests, I had to change the existing unit
 tests for `attachment_url_to_postid()`...which is always a sketchy
 proposition, so let me explain why I did this.

 The old unit tests used
 `WP_UnitTest_Factory->attachment->create_object()`, which does not
 actually perform an "upload"...and hence does **not** generate the
 `_wp_attachment_metadata` postmeta that the mod relies on.

 Hence, I changed the old tests to use
 `WP_UnitTest_Factory->attachment->create_upload_object()` which actually
 performs an "upload".

 Because of this change in the old unit tests, I would **really**
 appreciate close scrutiny of both the patch and the unit tests!!

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


More information about the wp-trac mailing list