wr_num 필드 값이 동시성 문제로 겹치는 경우 답변글에 대한 권한이 잘못 주어지는 등의 문제 다시 수정 #265
This commit is contained in:
@ -80,7 +80,7 @@ while ($row = sql_fetch_array($result))
|
|||||||
}
|
}
|
||||||
|
|
||||||
$sql = " insert into $move_write_table
|
$sql = " insert into $move_write_table
|
||||||
set wr_num = '$next_wr_num',
|
set wr_num = " . ($next_wr_num ? "'$next_wr_num'" : "(SELECT IFNULL(MIN(wr_num) - 1, -1) FROM $move_write_table sq) ") . ",
|
||||||
wr_reply = '{$row2['wr_reply']}',
|
wr_reply = '{$row2['wr_reply']}',
|
||||||
wr_is_comment = '{$row2['wr_is_comment']}',
|
wr_is_comment = '{$row2['wr_is_comment']}',
|
||||||
wr_comment = '{$row2['wr_comment']}',
|
wr_comment = '{$row2['wr_comment']}',
|
||||||
@ -119,13 +119,14 @@ while ($row = sql_fetch_array($result))
|
|||||||
|
|
||||||
$insert_id = sql_insert_id();
|
$insert_id = sql_insert_id();
|
||||||
|
|
||||||
|
if ($next_wr_num === 0) {
|
||||||
|
$tmp = sql_fetch("select wr_num from $move_write_table where wr_id = '$insert_id'");
|
||||||
|
$next_wr_num = $tmp['wr_num'];
|
||||||
|
}
|
||||||
|
|
||||||
// 코멘트가 아니라면
|
// 코멘트가 아니라면
|
||||||
if (!$row2['wr_is_comment'])
|
if (!$row2['wr_is_comment'])
|
||||||
{
|
{
|
||||||
if (! $row2['wr_reply']) {
|
|
||||||
$next_wr_num = -$insert_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
$save_parent = $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 ";
|
$sql3 = " select * from {$g5['board_file_table']} where bo_table = '$bo_table' and wr_id = '{$row2['wr_id']}' order by bf_no ";
|
||||||
@ -206,7 +207,7 @@ while ($row = sql_fetch_array($result))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sql_query(" update $move_write_table set wr_parent = '$save_parent', wr_num = '$next_wr_num' where wr_id = '$insert_id' ");
|
sql_query(" update $move_write_table set wr_parent = '$save_parent' where wr_id = '$insert_id' ");
|
||||||
|
|
||||||
if ($sw == 'move')
|
if ($sw == 'move')
|
||||||
$save[$cnt]['wr_id'] = $row2['wr_parent'];
|
$save[$cnt]['wr_id'] = $row2['wr_parent'];
|
||||||
|
|||||||
@ -258,8 +258,9 @@ if ($w == '' || $w == 'r') {
|
|||||||
$wr_reply = '';
|
$wr_reply = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// wr_num 서브쿼리 kkigomi 님 제안
|
||||||
$sql = " insert into $write_table
|
$sql = " insert into $write_table
|
||||||
set wr_num = '$wr_num',
|
set wr_num = " . ($w == 'r' ? "'$wr_num'" : "(SELECT IFNULL(MIN(wr_num) - 1, -1) FROM $write_table sq) ") . ",
|
||||||
wr_reply = '$wr_reply',
|
wr_reply = '$wr_reply',
|
||||||
wr_comment = 0,
|
wr_comment = 0,
|
||||||
ca_name = '$ca_name',
|
ca_name = '$ca_name',
|
||||||
@ -296,10 +297,8 @@ if ($w == '' || $w == 'r') {
|
|||||||
|
|
||||||
$wr_id = sql_insert_id();
|
$wr_id = sql_insert_id();
|
||||||
|
|
||||||
$add_wr_update_sql = ($wr_num === 0) ? ", wr_num = '-$wr_id' " : "";
|
|
||||||
|
|
||||||
// 부모 아이디에 UPDATE
|
// 부모 아이디에 UPDATE
|
||||||
sql_query(" update $write_table set wr_parent = '$wr_id' $add_wr_update_sql where wr_id = '$wr_id' ");
|
sql_query(" update $write_table set wr_parent = '$wr_id' where wr_id = '$wr_id' ");
|
||||||
|
|
||||||
// 새글 INSERT
|
// 새글 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']}' ) ");
|
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']}' ) ");
|
||||||
|
|||||||
Reference in New Issue
Block a user