From 0ccf86215fbfb2f703447ce44858ebf0040f4c33 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Mon, 3 May 2021 02:19:51 -0400 Subject: [PATCH] Fixes moving threads to a different board - it seems that it still chokes on posts with missing files - this seems to fix this and move the threads intact - i didn't investigate fully what is going on here --- inc/mod/pages.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index a555c57b..2016b2a9 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1382,8 +1382,12 @@ function mod_move($originBoard, $postID) { $post['files'] = json_decode($post['files'], TRUE); $post['has_file'] = true; foreach ($post['files'] as $i => &$file) { - $file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']; - $file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']; + if ($file['file'] !== 'deleted') { + $file['file_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']; + } + if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file'))) { + $file['thumb_path'] = sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']; + } } } else { $post['has_file'] = false; @@ -1422,8 +1426,12 @@ function mod_move($originBoard, $postID) { if ($post['has_file']) { // copy image foreach ($post['files'] as $i => &$file) { - clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']); - clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']); + if ($file['file'] !== 'deleted') { + clone_wrapped_with_exist_check($clone, $file['file_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['img'] . $file['file']); + } + if (isset($file['thumb']) && !in_array($file['thumb'], array('spoiler', 'deleted', 'file'))) { + clone_wrapped_with_exist_check($clone, $file['thumb_path'], sprintf($config['board_path'], $board['uri']) . $config['dir']['thumb'] . $file['thumb']); + } } } // insert reply