Fix SQL query for job queue processing, fix issue where admin images were trying to go through the image resize function.
This commit is contained in:
parent
67d2b8e9c5
commit
329f28f08b
|
@ -43,14 +43,10 @@ class WC_Regenerate_Images_Request extends WP_Background_Process {
|
|||
* @return bool
|
||||
*/
|
||||
protected function task( $item ) {
|
||||
$message = $this->get_message( $item );
|
||||
$this->really_long_running_task();
|
||||
|
||||
if ( ! is_array( $message ) && ! isset( $message['attachment_id'] ) ) {
|
||||
if ( ! is_array( $item ) && ! isset( $item['attachment_id'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$attachment_id = absint( $message['attachment_id'] );
|
||||
$attachment_id = absint( $item['attachment_id'] );
|
||||
|
||||
$attachment = get_post( $attachment_id );
|
||||
if ( ! $attachment || 'attachment' !== $attachment->post_type || 'image/' !== substr( $attachment->post_mime_type, 0, 6 ) ) {
|
||||
|
|
|
@ -54,6 +54,10 @@ class WC_Regenerate_Images {
|
|||
return $image;
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
return $image;
|
||||
}
|
||||
|
||||
$imagemeta = wp_get_attachment_metadata( $attachment_id );
|
||||
|
||||
if ( false === $imagemeta || empty( $imagemeta ) ) {
|
||||
|
@ -177,11 +181,9 @@ class WC_Regenerate_Images {
|
|||
"SELECT ID
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = 'attachment'
|
||||
AND post_parent IN ( SELECT ID FROM $wpdb->posts WHERE post_type IN ( 'product','product_variation' ) )
|
||||
AND post_mime_type LIKE 'image/%'
|
||||
ORDER BY ID DESC"
|
||||
);
|
||||
|
||||
foreach ( $images as $image ) {
|
||||
self::$background_process->push_to_queue( array(
|
||||
'attachment_id' => $image->ID,
|
||||
|
|
Loading…
Reference in New Issue