mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-16 00:54:12 +03:00
Remove Settings::update method
It was too slow
This commit is contained in:
parent
bf483e4abc
commit
b5020645be
@ -66,7 +66,6 @@ class CronController extends AbstractController
|
|||||||
|
|
||||||
// Update time of last cron run
|
// Update time of last cron run
|
||||||
Settings::set('_last_cron_run', time());
|
Settings::set('_last_cron_run', time());
|
||||||
Settings::update();
|
|
||||||
|
|
||||||
if (!$quiet) {
|
if (!$quiet) {
|
||||||
// TODO: May be localize it
|
// TODO: May be localize it
|
||||||
|
@ -210,7 +210,6 @@ class CommonController extends AbstractController
|
|||||||
foreach ($params as $key => $value) {
|
foreach ($params as $key => $value) {
|
||||||
Settings::set($key, $value);
|
Settings::set($key, $value);
|
||||||
}
|
}
|
||||||
Settings::update();
|
|
||||||
|
|
||||||
// Update styles params
|
// Update styles params
|
||||||
ChatStyle::setDefaultStyle($chat_style);
|
ChatStyle::setDefaultStyle($chat_style);
|
||||||
|
@ -45,7 +45,6 @@ class FeaturesController extends AbstractController
|
|||||||
|
|
||||||
if (Settings::get('featuresversion') != FEATURES_VERSION) {
|
if (Settings::get('featuresversion') != FEATURES_VERSION) {
|
||||||
Settings::set('featuresversion', FEATURES_VERSION);
|
Settings::set('featuresversion', FEATURES_VERSION);
|
||||||
Settings::update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all needed options and fill form with them.
|
// 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';
|
$value = $request->request->get($opt) == 'on' ? '1' : '0';
|
||||||
Settings::set($opt, $value);
|
Settings::set($opt, $value);
|
||||||
}
|
}
|
||||||
Settings::update();
|
|
||||||
|
|
||||||
// Redirect the current operator to the same page using GET method.
|
// Redirect the current operator to the same page using GET method.
|
||||||
$redirect_to = $this->generateUrl(
|
$redirect_to = $this->generateUrl(
|
||||||
|
@ -180,7 +180,6 @@ class PerformanceController extends AbstractController
|
|||||||
foreach ($params as $key => $value) {
|
foreach ($params as $key => $value) {
|
||||||
Settings::set($key, $value);
|
Settings::set($key, $value);
|
||||||
}
|
}
|
||||||
Settings::update();
|
|
||||||
|
|
||||||
// Redirect the current operator to the same page using get method.
|
// Redirect the current operator to the same page using get method.
|
||||||
$redirect_to = $this->generateUrl('settings_performance', array('stored' => true));
|
$redirect_to = $this->generateUrl('settings_performance', array('stored' => true));
|
||||||
|
@ -158,27 +158,21 @@ class Settings
|
|||||||
public static function set($name, $value)
|
public static function set($name, $value)
|
||||||
{
|
{
|
||||||
$instance = self::getInstance();
|
$instance = self::getInstance();
|
||||||
|
// Update value in the instance
|
||||||
$instance->settings[$name] = $value;
|
$instance->settings[$name] = $value;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Update value in the database
|
||||||
* Updates settings in database.
|
|
||||||
*/
|
|
||||||
public static function update()
|
|
||||||
{
|
|
||||||
$instance = self::getInstance();
|
|
||||||
$db = Database::getInstance();
|
$db = Database::getInstance();
|
||||||
foreach ($instance->settings as $key => $value) {
|
if (!isset($instance->settingsInDb[$name])) {
|
||||||
if (!isset($instance->settingsInDb[$key])) {
|
|
||||||
$db->query(
|
|
||||||
"INSERT INTO {config} (vckey) VALUES (?)",
|
|
||||||
array($key)
|
|
||||||
);
|
|
||||||
$instance->settingsInDb[$key] = true;
|
|
||||||
}
|
|
||||||
$db->query(
|
$db->query(
|
||||||
"UPDATE {config} SET vcvalue=? WHERE vckey=?",
|
"INSERT INTO {config} (vckey, vcvalue) VALUES (:name, :value)",
|
||||||
array($value, $key)
|
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)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,6 @@ class ChatStyle extends AbstractHandlebarsPoweredStyle implements StyleInterface
|
|||||||
public static function setDefaultStyle($style_name)
|
public static function setDefaultStyle($style_name)
|
||||||
{
|
{
|
||||||
Settings::set('chat_style', $style_name);
|
Settings::set('chat_style', $style_name);
|
||||||
Settings::update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +82,6 @@ class InvitationStyle extends AbstractStyle implements StyleInterface
|
|||||||
public static function setDefaultStyle($style_name)
|
public static function setDefaultStyle($style_name)
|
||||||
{
|
{
|
||||||
Settings::set('invitation_style', $style_name);
|
Settings::set('invitation_style', $style_name);
|
||||||
Settings::update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,7 +95,6 @@ class PageStyle extends AbstractHandlebarsPoweredStyle implements StyleInterface
|
|||||||
public static function setDefaultStyle($style_name)
|
public static function setDefaultStyle($style_name)
|
||||||
{
|
{
|
||||||
Settings::set('page_style', $style_name);
|
Settings::set('page_style', $style_name);
|
||||||
Settings::update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user