another check for empty results

This commit is contained in:
Matthew Exon 2021-04-26 20:14:54 +02:00
parent b3d5e6b286
commit e312ab04b9

View file

@ -253,9 +253,11 @@ function phototrack_tidy() {
q('CREATE TABLE IF NOT EXISTS `phototrack-temp` (`resource-id` char(255) not null)'); q('CREATE TABLE IF NOT EXISTS `phototrack-temp` (`resource-id` char(255) not null)');
q('INSERT INTO `phototrack-temp` SELECT DISTINCT(`resource-id`) FROM photo WHERE photo.`created` < DATE_SUB(NOW(), INTERVAL 2 MONTH)'); q('INSERT INTO `phototrack-temp` SELECT DISTINCT(`resource-id`) FROM photo WHERE photo.`created` < DATE_SUB(NOW(), INTERVAL 2 MONTH)');
$rows = q('SELECT `phototrack-temp`.`resource-id` FROM `phototrack-temp` LEFT OUTER JOIN phototrack_photo_use ON (`phototrack-temp`.`resource-id` = phototrack_photo_use.`resource-id`) WHERE phototrack_photo_use.id IS NULL limit ' . /*$batch_size*/1000); $rows = q('SELECT `phototrack-temp`.`resource-id` FROM `phototrack-temp` LEFT OUTER JOIN phototrack_photo_use ON (`phototrack-temp`.`resource-id` = phototrack_photo_use.`resource-id`) WHERE phototrack_photo_use.id IS NULL limit ' . /*$batch_size*/1000);
foreach ($rows as $row) { if (DBA::isResult($ms_item_ids)) {
Logger::debug('phototrack: remove photo ' . $row['resource-id']); foreach ($rows as $row) {
q('DELETE FROM photo WHERE `resource-id` = "' . $row['resource-id'] . '"'); Logger::debug('phototrack: remove photo ' . $row['resource-id']);
q('DELETE FROM photo WHERE `resource-id` = "' . $row['resource-id'] . '"');
}
} }
q('DROP TABLE `phototrack-temp`'); q('DROP TABLE `phototrack-temp`');
Logger::info('phototrack_tidy: deleted ' . count($rows) . ' photos'); Logger::info('phototrack_tidy: deleted ' . count($rows) . ' photos');