동시성 문제로 wr_seo_title 값이 중복되는 문제 수정 #293
This commit is contained in:
@ -253,10 +253,61 @@ function exist_seo_url($type, $seo_title, $write_table, $sql_id=0){
|
||||
return '';
|
||||
}
|
||||
|
||||
function check_case_exist_title($data, $case=G5_BBS_DIR, $is_redirect=false) {
|
||||
global $config, $g5, $board;
|
||||
|
||||
if ((int) $config['cf_bbs_rewrite'] !== 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
$seo_title = '';
|
||||
$redirect_url = '';
|
||||
|
||||
if ($case == G5_BBS_DIR && isset($data['wr_seo_title'])) {
|
||||
$db_table = $g5['write_prefix'].$board['bo_table'];
|
||||
|
||||
if (exist_seo_url($case, $data['wr_seo_title'], $db_table, $data['wr_id'])) {
|
||||
$seo_title = $data['wr_seo_title'].'-'.$data['wr_id'];
|
||||
$sql = " update `{$db_table}` set wr_seo_title = '".sql_real_escape_string($seo_title)."' where wr_id = '{$data['wr_id']}' ";
|
||||
sql_query($sql, false);
|
||||
|
||||
get_write($db_table, $data['wr_id'], false);
|
||||
$redirect_url = get_pretty_url($board['bo_table'], $data['wr_id']);
|
||||
}
|
||||
} else if ($case == G5_CONTENT_DIR && isset($data['co_seo_title'])) {
|
||||
$db_table = $g5['content_table'];
|
||||
|
||||
if (exist_seo_url($case, $data['co_seo_title'], $db_table, $data['co_id'])) {
|
||||
$seo_title = $data['co_seo_title'].'-'.substr(get_random_token_string(4), 4);
|
||||
$sql = " update `{$db_table}` set co_seo_title = '".sql_real_escape_string($seo_title)."' where co_id = '{$data['co_id']}' ";
|
||||
sql_query($sql, false);
|
||||
|
||||
get_content_db($data['co_id'], false);
|
||||
g5_delete_cache_by_prefix('content-' . $data['co_id'] . '-');
|
||||
$redirect_url = get_pretty_url($case, $data['co_id']);
|
||||
}
|
||||
} else if (defined('G5_SHOP_DIR') && $case == G5_SHOP_DIR && isset($data['it_seo_title'])) {
|
||||
$db_table = $g5['g5_shop_item_table'];
|
||||
|
||||
if (shop_exist_check_seo_title($data['it_seo_title'], $case, $db_table, $data['it_id'])) {
|
||||
$seo_title = $data['it_seo_title'].'-'.substr(get_random_token_string(4), 4);
|
||||
$sql = " update `{$db_table}` set it_seo_title = '".sql_real_escape_string($seo_title)."' where it_id = '{$data['it_id']}' ";
|
||||
sql_query($sql, false);
|
||||
|
||||
get_shop_item($data['it_id'], false);
|
||||
$redirect_url = get_pretty_url($case, $data['it_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($is_redirect && $seo_title && $redirect_url) {
|
||||
goto_url($redirect_url);
|
||||
}
|
||||
}
|
||||
|
||||
function exist_seo_title_recursive($type, $seo_title, $write_table, $sql_id=0){
|
||||
static $count = 0;
|
||||
|
||||
$seo_title_add = ($count > 0) ? utf8_strcut($seo_title, 200 - ($count+1), '')."-$count" : $seo_title;
|
||||
$seo_title_add = ($count > 0) ? utf8_strcut($seo_title, 100000 - ($count+1), '')."-$count" : $seo_title;
|
||||
|
||||
if( ! exist_seo_url($type, $seo_title_add, $write_table, $sql_id) ){
|
||||
return $seo_title_add;
|
||||
@ -264,7 +315,7 @@ function exist_seo_title_recursive($type, $seo_title, $write_table, $sql_id=0){
|
||||
|
||||
$count++;
|
||||
|
||||
if( $count > 198 ){
|
||||
if( $count > 99998 ){
|
||||
return $seo_title_add;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user