Remove Settings::update method

It was too slow
This commit is contained in:
Dmitriy Simushev 2014-10-29 15:02:55 +00:00
parent bf483e4abc
commit b5020645be
8 changed files with 11 additions and 25 deletions

View File

@ -66,7 +66,6 @@ class CronController extends AbstractController
// Update time of last cron run
Settings::set('_last_cron_run', time());
Settings::update();
if (!$quiet) {
// TODO: May be localize it

View File

@ -210,7 +210,6 @@ class CommonController extends AbstractController
foreach ($params as $key => $value) {
Settings::set($key, $value);
}
Settings::update();
// Update styles params
ChatStyle::setDefaultStyle($chat_style);

View File

@ -45,7 +45,6 @@ class FeaturesController extends AbstractController
if (Settings::get('featuresversion') != FEATURES_VERSION) {
Settings::set('featuresversion', FEATURES_VERSION);
Settings::update();
}
// Load all needed options and fill form with them.
@ -84,7 +83,6 @@ class FeaturesController extends AbstractController
$value = $request->request->get($opt) == 'on' ? '1' : '0';
Settings::set($opt, $value);
}
Settings::update();
// Redirect the current operator to the same page using GET method.
$redirect_to = $this->generateUrl(

View File

@ -180,7 +180,6 @@ class PerformanceController extends AbstractController
foreach ($params as $key => $value) {
Settings::set($key, $value);
}
Settings::update();
// Redirect the current operator to the same page using get method.
$redirect_to = $this->generateUrl('settings_performance', array('stored' => true));

View File

@ -158,27 +158,21 @@ class Settings
public static function set($name, $value)
{
$instance = self::getInstance();
// Update value in the instance
$instance->settings[$name] = $value;
}
/**
* Updates settings in database.
*/
public static function update()
{
$instance = self::getInstance();
// Update value in the database
$db = Database::getInstance();
foreach ($instance->settings as $key => $value) {
if (!isset($instance->settingsInDb[$key])) {
$db->query(
"INSERT INTO {config} (vckey) VALUES (?)",
array($key)
);
$instance->settingsInDb[$key] = true;
}
if (!isset($instance->settingsInDb[$name])) {
$db->query(
"UPDATE {config} SET vcvalue=? WHERE vckey=?",
array($value, $key)
"INSERT INTO {config} (vckey, vcvalue) VALUES (:name, :value)",
array(':name' => $name, ':value' => $value)
);
$instance->settingsInDb[$name] = true;
} else {
$db->query(
'UPDATE {config} SET vcvalue=:value WHERE vckey=:name',
array(':name' => $name, ':value' => $value)
);
}
}

View File

@ -117,7 +117,6 @@ class ChatStyle extends AbstractHandlebarsPoweredStyle implements StyleInterface
public static function setDefaultStyle($style_name)
{
Settings::set('chat_style', $style_name);
Settings::update();
}
/**

View File

@ -82,7 +82,6 @@ class InvitationStyle extends AbstractStyle implements StyleInterface
public static function setDefaultStyle($style_name)
{
Settings::set('invitation_style', $style_name);
Settings::update();
}
/**

View File

@ -95,7 +95,6 @@ class PageStyle extends AbstractHandlebarsPoweredStyle implements StyleInterface
public static function setDefaultStyle($style_name)
{
Settings::set('page_style', $style_name);
Settings::update();
}
/**