Skip to content

Commit

Permalink
wr_num 필드 값이 동시성 문제로 겹치는 경우 답변글에 대한 권한이 잘못 주어지는 등의 문제 #265
Browse files Browse the repository at this point in the history
  • Loading branch information
thisgun committed Aug 16, 2023
1 parent 5d4ba10 commit 876534a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions bbs/move_update.php
Expand Up @@ -49,7 +49,9 @@
$count_write = 0;
$count_comment = 0;

$next_wr_num = get_next_num($move_write_table);
// get_next_num 함수는 mysql 지연시 중복이 될수 있는 문제로 더 이상 사용하지 않습니다.
// $next_wr_num = get_next_num($move_write_table);
$next_wr_num = 0;

$sql2 = " select * from $write_table where wr_num = '$wr_num' order by wr_parent, wr_is_comment, wr_comment desc, wr_id ";
$result2 = sql_query($sql2);
Expand Down Expand Up @@ -120,6 +122,10 @@
// 코멘트가 아니라면
if (!$row2['wr_is_comment'])
{
if (! $row2['wr_reply']) {
$next_wr_num = -$insert_id;
}

$save_parent = $insert_id;

$sql3 = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row2['wr_id']}' order by bf_no ";
Expand Down Expand Up @@ -200,7 +206,7 @@
}
}

sql_query(" update $move_write_table set wr_parent = '$save_parent' where wr_id = '$insert_id' ");
sql_query(" update $move_write_table set wr_parent = '$save_parent', wr_num = '$next_wr_num' where wr_id = '$insert_id' ");

if ($sw == 'move')
$save[$cnt]['wr_id'] = $row2['wr_parent'];
Expand Down
8 changes: 6 additions & 2 deletions bbs/write_update.php
Expand Up @@ -252,7 +252,9 @@
$wr_num = $write['wr_num'];
$wr_reply = $reply;
} else {
$wr_num = get_next_num($write_table);
// get_next_num 함수는 mysql 지연시 중복이 될수 있는 문제로 더 이상 사용하지 않습니다.
// $wr_num = get_next_num($write_table);
$wr_num = 0;
$wr_reply = '';
}

Expand Down Expand Up @@ -294,8 +296,10 @@

$wr_id = sql_insert_id();

$add_wr_update_sql = ($wr_num === 0) ? ", wr_num = '-$wr_id' " : "";

// 부모 아이디에 UPDATE
sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' ");
sql_query(" update $write_table set wr_parent = '$wr_id' $add_wr_update_sql where wr_id = '$wr_id' ");

// 새글 INSERT
sql_query(" insert into {$g5['board_new_table']} ( bo_table, wr_id, wr_parent, bn_datetime, mb_id ) values ( '{$bo_table}', '{$wr_id}', '{$wr_id}', '".G5_TIME_YMDHIS."', '{$member['mb_id']}' ) ");
Expand Down

0 comments on commit 876534a

Please sign in to comment.