mirror of
				https://github.com/Mibew/mibew.git
				synced 2025-10-31 02:25:51 +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
 | ||||
|         Settings::set('_last_cron_run', time()); | ||||
|         Settings::update(); | ||||
| 
 | ||||
|         if (!$quiet) { | ||||
|             // TODO: May be localize it
 | ||||
|  | ||||
| @ -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); | ||||
|  | ||||
| @ -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( | ||||
|  | ||||
| @ -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)); | ||||
|  | ||||
| @ -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) | ||||
|             ); | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -117,7 +117,6 @@ class ChatStyle extends AbstractHandlebarsPoweredStyle implements StyleInterface | ||||
|     public static function setDefaultStyle($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) | ||||
|     { | ||||
|         Settings::set('invitation_style', $style_name); | ||||
|         Settings::update(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -95,7 +95,6 @@ class PageStyle extends AbstractHandlebarsPoweredStyle implements StyleInterface | ||||
|     public static function setDefaultStyle($style_name) | ||||
|     { | ||||
|         Settings::set('page_style', $style_name); | ||||
|         Settings::update(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user