Developer forum

Forum » CMS - Standard features » Global settings writing to the wrong file

Global settings writing to the wrong file

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a site with a separate database.config file to change the database connection for a staging server:

The Database.config contains just the connection info, like so:

<?xml version="1.0"?>
<Globalsettings>
  <System>
    <Database>
      <Password>
      </Password>
      <Type>
      </Type>
      <UserName>
      </UserName>
      <Database>Swift-122
      </Database>
      <SQLServer>.
      </SQLServer>
      <DWWebIP>
      </DWWebIP>
      <SQLServer2>
      </SQLServer2>
      <Database2>
      </Database2>
      <UserName2>
      </UserName2>
      <Password2>
      </Password2>
      <IntegratedSecurity>True</IntegratedSecurity>
      <ConnectionString>
      </ConnectionString>
      <ConnectionString2>
      </ConnectionString2>
    </Database>
  </System>
</Globalsettings>

That all works fine (and has been since forever I think).

However, when I now make changes to settings, they are stored in the database.config file, not in GlobalSettings.config. I changed for example the SMTP settings and now database.config looks as follows:

<?xml version="1.0"?>
<Globalsettings>
  <System>
    <Database>
      <Password>
      </Password>
      <Type>
      </Type>
      <UserName>
      </UserName>
      <Database>Swift-122
      </Database>
      <SQLServer>.
      </SQLServer>
      <DWWebIP>
      </DWWebIP>
      <SQLServer2>
      </SQLServer2>
      <Database2>
      </Database2>
      <UserName2>
      </UserName2>
      <Password2>
      </Password2>
      <IntegratedSecurity>True</IntegratedSecurity>
      <ConnectionString>
      </ConnectionString>
      <ConnectionString2>
      </ConnectionString2>
    </Database>
    <MailServer>
      <SaveAllMailsToDisk>True</SaveAllMailsToDisk>
      <ByPassRecipients>True</ByPassRecipients>
      <ByPassRecipientsSendTo>you@example.com</ByPassRecipientsSendTo>
      <ByPassMailFrom>
      </ByPassMailFrom>
    </MailServer>
  </System>
</Globalsettings>

Now I have my settings in two files which make it hard to refresh staging with a copy of production without changing the database config file.

Is this a bug? It reproduces for me on 9.16.3 and 9.17.2 at least.

Imar


Replies

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Config files are prioritized by file names in reverse order.

When settings are persisted the system configuration will go through each config file.
If it finds the setting in a config file then it will update that one - otherwise it will continue and fallback to using the config file with lowest priority.

Consider renaming Database.config to GlobalSettings.Database.config or something like that.

Your setup

  1. GlobalSettings.config
  2. Database.config (lowest priority - used as fallback when key is not found in config files with higher priority)

Recommended setup

  1. GlobalSettings.Database.config
  2. GlobalSettings.config (lowest priority - used as fallback when key is not found in config files with higher priority)

If you add a new config file to a running application (or rename an existing config file) then it might not be detected by the system. Try to restart the application.

Votes for this answer: 1
 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Ah, that explains it. I didn't know about the file name ordering. I thought it read global settings and then other files and then kept track of which section came from which file.

I'll merge my files and then rename the database.config file as you suggest.

Thanks!

 

You must be logged in to post in the forum