Prechádzať zdrojové kódy

Properly fix #1180 this time - turns out saving general settings overwrote the two boolean DB settings...

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 10 rokov pred
rodič
commit
c8f52fb87c
1 zmenil súbory, kde vykonal 12 pridanie a 10 odobranie
  1. 12 10
      Sources/ManageServer.php

+ 12 - 10
Sources/ManageServer.php

@@ -177,6 +177,9 @@ function ModifyGeneralSettings($return_config = false)
 	{
 		call_integration_hook('integrate_save_general_settings');
 
+		// Don't overwrite the two boolean DB-related settings
+		$context['area'] = 'server';
+
 		saveSettings($config_vars);
 		$_SESSION['adm-save'] = true;
 		redirectexit('action=admin;area=serversettings;sa=general;' . $context['session_var'] . '=' . $context['session_id']);
@@ -200,7 +203,7 @@ function ModifyGeneralSettings($return_config = false)
  */
 function ModifyDatabaseSettings($return_config = false)
 {
-	global $scripturl, $context, $txt, $boarddir, $maintenance;
+	global $scripturl, $context, $txt, $boarddir;
 
 	/* If you're writing a mod, it's a bad idea to add things here....
 		For each option:
@@ -234,9 +237,8 @@ function ModifyDatabaseSettings($return_config = false)
 	{
 		call_integration_hook('integrate_save_database_settings');
 
-        // Don't overwrite the maintenance value!
-        if ($maintenance === 1)
-            $context['maintenance'] = true;
+		// Don't accidentally disable maintenance mode..
+		$context['area'] = 'db';
 
 		saveSettings($config_vars);
 		$_SESSION['adm-save'] = true;
@@ -927,11 +929,11 @@ function saveSettings(&$config_vars)
 		'cache_enable',
 	);
 
-	// All the checkboxes.
-	$config_bools = array(
-		'db_persist', 'db_error_send',
-		'maintenance',
-	);
+	// All the checkboxes - this varies depending on where we're coming from
+	if ($context['area'] == 'db')
+		$config_bools = array('db_persist', 'db_error_send');
+	elseif ($context['area'] == 'server')
+		$config_bools = array('maintenance');
 
 	// Now sort everything into a big array, and figure out arrays and etc.
 	$new_settings = array();
@@ -954,7 +956,7 @@ function saveSettings(&$config_vars)
 	{
 		if (!empty($_POST[$key]))
 			$new_settings[$key] = '1';
-		elseif ($key != 'maintenance' || !isset($context['maintenance']))
+		else
 			$new_settings[$key] = '0';
 	}