Easy-to-fix bug with rescanning
-
In the rescan function in img-optm.php file, there are two queries (the main one, and then the check for continuation) that do this:
$q = "SELECT distinct b.post_id, b.meta_value FROM <code>$wpdb->posts</code> a LEFT JOIN <code>$wpdb->postmeta</code> b ON b.post_id = a.ID LEFT JOIN <code>$this->_table_img_optm</code> c ON c.post_id = a.ID
If an image has 10 thumbnails, it appears 10 times in the img_optm table. The last left join then means you get the same results back in 10x duplicate. For each new thumbnail it detects it then adds 10 new entries into the table.
This should be:
$q = "SELECT distinct b.post_id, b.meta_value FROM <code>$wpdb->posts</code> a LEFT JOIN <code>$wpdb->postmeta</code> b ON b.post_id = a.ID LEFT JOIN <code>$this->_table_img_optm</code> c ON c.post_id = a.ID
in both places. This massively speeds up the regeneration process.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Easy-to-fix bug with rescanning’ is closed to new replies.