From 08ae0304bb0ece739ee4e36e2aaec48ca5286b49 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 21 Aug 2024 15:20:05 +0200 Subject: [PATCH] (cp 545e81e) Fix for #2114: Check for photos missing md5sum before trying to update md5sums --- include/ws_functions/pwg.images.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index c1a3097c9..a51bc8036 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -2641,8 +2641,14 @@ function ws_images_setMd5sum($params, $service) include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); - $md5sum_ids_to_add = array_slice(get_photos_no_md5sum(), 0, $params['block_size']); - $added_count = add_md5sum($md5sum_ids_to_add); + $nb_no_md5sum = count(get_photos_no_md5sum()); + $added_count = 0; + + if ($nb_no_md5sum > 0) + { + $md5sum_ids_to_add = array_slice(get_photos_no_md5sum(), 0, $params['block_size']); + $added_count = add_md5sum($md5sum_ids_to_add); + } return array( 'nb_added' => $added_count,