From a0b2ef3d041ba799ea671c8fb22a58a0f4a1e8fb Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Mon, 26 Apr 2021 20:14:54 +0200 Subject: [PATCH] another check for empty results --- phototrack/phototrack.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phototrack/phototrack.php b/phototrack/phototrack.php index b5f39a1e..9f6c86d1 100644 --- a/phototrack/phototrack.php +++ b/phototrack/phototrack.php @@ -253,9 +253,11 @@ function phototrack_tidy() { 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)'); $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) { - Logger::debug('phototrack: remove photo ' . $row['resource-id']); - q('DELETE FROM photo WHERE `resource-id` = "' . $row['resource-id'] . '"'); + if (DBA::isResult($ms_item_ids)) { + foreach ($rows as $row) { + Logger::debug('phototrack: remove photo ' . $row['resource-id']); + q('DELETE FROM photo WHERE `resource-id` = "' . $row['resource-id'] . '"'); + } } q('DROP TABLE `phototrack-temp`'); Logger::info('phototrack_tidy: deleted ' . count($rows) . ' photos');