Browse Source

Bugfix - Move thread now works with update to handle multiple fileshashes

main
PupperWoff 7 years ago
committed by -
parent
commit
fcd7976881
  1. 53
      inc/mod/pages.php

53
inc/mod/pages.php

@ -1252,9 +1252,26 @@ function mod_move_reply($originBoard, $postID) {
if (!openBoard($targetBoard))
error($config['error']['noboard']);
// get all filehashes associated with post
$post['allhashes'] = '';
$hashquery = prepare('SELECT `filehash` FROM ``filehashes`` WHERE `board` = :board AND `post` = :post');
$hashquery->bindValue(':board', $originBoard, PDO::PARAM_STR);
$hashquery->bindValue(':post', $postID, PDO::PARAM_INT);
$hashquery->execute() or error(db_error($hashquery));
while ($hash = $hashquery->fetch(PDO::FETCH_ASSOC)) {
$post['allhashes'] .= $hash['filehash'] . ":";
}
$post['allhashes'] = substr($post['allhashes'], 0, -1);
// create the new post
$newID = post($post);
// delete old file hash list
$hashquery = prepare('DELETE FROM ``filehashes`` WHERE `board` = :board AND `post` = :post');
$hashquery->bindValue(':board', $originBoard, PDO::PARAM_STR);
$hashquery->bindValue(':post', $postID, PDO::PARAM_INT);
$hashquery->execute() or error(db_error($hashquery));
if ($post['has_file']) {
foreach ($post['files'] as $i => &$file) {
// move the image
@ -1355,9 +1372,26 @@ function mod_move($originBoard, $postID) {
if (!openBoard($targetBoard))
error($config['error']['noboard']);
// Get all filehashes associated with post
$post['allhashes'] = '';
$hashquery = prepare('SELECT `filehash` FROM ``filehashes`` WHERE `board` = :board AND `post` = :post');
$hashquery->bindValue(':board', $originBoard, PDO::PARAM_STR);
$hashquery->bindValue(':post', $postID, PDO::PARAM_INT);
$hashquery->execute() or error(db_error($hashquery));
while ($hash = $hashquery->fetch(PDO::FETCH_ASSOC)) {
$post['allhashes'] .= $hash['filehash'] . ":";
}
$post['allhashes'] = substr($post['allhashes'], 0, -1);
// create the new thread
$newID = post($post);
// Delete old file hash list
$hashquery = prepare('DELETE FROM ``filehashes`` WHERE `board` = :board AND `post` = :post');
$hashquery->bindValue(':board', $originBoard, PDO::PARAM_STR);
$hashquery->bindValue(':post', $postID, PDO::PARAM_INT);
$hashquery->execute() or error(db_error($hashquery));
$op = $post;
$op['id'] = $newID;
@ -1437,9 +1471,26 @@ function mod_move($originBoard, $postID) {
}
}
}
// Get all filehashes associated with post
$post['allhashes'] = '';
$hashquery = prepare('SELECT `filehash` FROM ``filehashes`` WHERE `board` = :board AND `post` = :post ORDER BY `id`');
$hashquery->bindValue(':board', $originBoard, PDO::PARAM_STR);
$hashquery->bindValue(':post', $post['id'], PDO::PARAM_INT);
$hashquery->execute() or error(db_error($hashquery));
while ($hash = $hashquery->fetch(PDO::FETCH_ASSOC)) {
$post['allhashes'] .= $hash['filehash'] . ":";
}
$post['allhashes'] = substr($post['allhashes'], 0, -1);
// insert reply
$newIDs[$post['id']] = $newPostID = post($post);
// Delete old file hash list
$hashquery = prepare('DELETE FROM ``filehashes`` WHERE `board` = :board AND `post` = :post');
$hashquery->bindValue(':board', $originBoard, PDO::PARAM_STR);
$hashquery->bindValue(':post', $post['id'], PDO::PARAM_INT);
$hashquery->execute() or error(db_error($hashquery));
if (!empty($post['tracked_cites'])) {
$insert_rows = array();

Loading…
Cancel
Save