Skip to content

CLI fetches ALL images from db, rather than the defined limit #17

@jespervnielsen

Description

@jespervnielsen

This sql, fetches ALL images.
On sites with 100.000 images, this will properbly die.

$query = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_mime_type
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->posts.post_type = 'attachment'
AND $wpdb->posts.post_mime_type LIKE 'image/%'
AND $queryImageTypes
AND $wpdb->postmeta.meta_key = '_wp_attachment_metadata'
AND $wpdb->postmeta.meta_value NOT LIKE '$optimus_query'
$id_query
ORDER BY $wpdb->posts.ID DESC";
return $wpdb->get_results($query, ARRAY_A);

We try to run some re-creating of .webp Images, but we suspect this one to be the root cause of why its not possible.

We do it via WP CLi, and the above sql, doesnt use LIMIT params, in order to listen on how many it should fetch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions