mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 23:27:39 +02:00
Media: Don't unnecessarily check for a valid attachment before getting meta.
This makes `wp_get_attachment_metadata()` run significantly faster. See ticket for benchmarking. Props Tkama, donmhico. Fixes #50679. Built from https://develop.svn.wordpress.org/trunk@49084 git-svn-id: http://core.svn.wordpress.org/trunk@48846 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e9d572f431
commit
b108d4db71
@ -5992,13 +5992,12 @@ function wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file ) {
|
|||||||
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
|
function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
|
||||||
$attachment_id = (int) $attachment_id;
|
$attachment_id = (int) $attachment_id;
|
||||||
|
|
||||||
$post = get_post( $attachment_id );
|
$data = get_post_meta( $attachment_id, '_wp_attachment_metadata', true );
|
||||||
if ( ! $post ) {
|
|
||||||
|
if ( empty( $data ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
|
|
||||||
|
|
||||||
if ( $unfiltered ) {
|
if ( $unfiltered ) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
@ -6012,7 +6011,7 @@ function wp_get_attachment_metadata( $attachment_id = 0, $unfiltered = false ) {
|
|||||||
* if the object does not exist.
|
* if the object does not exist.
|
||||||
* @param int $attachment_id Attachment post ID.
|
* @param int $attachment_id Attachment post ID.
|
||||||
*/
|
*/
|
||||||
return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
|
return apply_filters( 'wp_get_attachment_metadata', $data, $attachment_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-49083';
|
$wp_version = '5.6-alpha-49084';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user