Opened 4 years ago
Last modified 4 years ago
#52389 accepted defect (bug)
Consistently check for non-empty post ID in attachment functions
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | needs-patch |
Focuses: | Cc: |
Description
As a result of the changes in [49084] and [50039], wp_get_attachment_metadata()
conditionally calls get_post()
if the attachment ID is not passed:
$attachment_id = (int) $attachment_id; if ( ! $attachment_id ) { $post = get_post(); if ( ! $post ) { return false; } $attachment_id = $post->ID; }
This is not really consistent with other attachment functions, which just always call get_post()
unconditionally:
$attachment_id = (int) $attachment_id; $post = get_post( $attachment_id );
Let's bring some consistency here, there is no reason for these minor differences.
This applies at least to:
wp_get_attachment_metadata()
wp_get_attachment_url()
wp_get_attachment_caption()
wp_get_attachment_thumb_file()
wp_get_attachment_thumb_url()
Change History (2)
Note: See
TracTickets for help on using
tickets.