mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
Fix race condition for updating post/topic/etc. counter. (reported by BartVB)
please do not try such fixes at home - the correct solution would be to create a second config table with integer columns. ;) git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9398 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -164,6 +164,37 @@ function set_config($config_name, $config_value, $is_dynamic = false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dynamic config value with arithmetic operation.
|
||||
*/
|
||||
function set_config_count($config_name, $increment, $is_dynamic = false)
|
||||
{
|
||||
global $db, $cache;
|
||||
|
||||
switch ($db->sql_layer)
|
||||
{
|
||||
case 'firebird':
|
||||
$sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as CHAR)';
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
$sql_update = 'int4(config_value) + ' . (int) $increment;
|
||||
break;
|
||||
|
||||
// MySQL, SQlite, mssql, mssql_odbc, oracle
|
||||
default:
|
||||
$sql_update = 'config_value + ' . (int) $increment;
|
||||
break;
|
||||
}
|
||||
|
||||
$db->sql_query('UPDATE ' . CONFIG_TABLE . ' SET config_value = ' . $sql_update . " WHERE config_name = '" . $db->sql_escape($config_name) . "'");
|
||||
|
||||
if (!$is_dynamic)
|
||||
{
|
||||
$cache->destroy('config');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an alphanumeric random string of given length
|
||||
*/
|
||||
|
Reference in New Issue
Block a user