The secret plan to store configuration in files
There does not seem to be any discussion about a file-based approach to saving configuration information in Drupal. Agaric comes to this conclusion after extensive Googling (see the keyword details of this post; by the way, I can confirm that word order matters when doing Google searches, even in the absence of quotation marks).
I had considered the .ini file approach to saving variables before, for themes and looked into the idea a few times. Each time I decided I must be crazy since there was no discussion about it whatsoever.
So here's the crazy idea: all these one-off variables clogging the variable table and being entered into the PHP memory space on every request, and indeed all conceivable configuration (as distinguished from user-generated data) should be stored in files, not the database.
Now, I understand that many uses for variable_set and variable_get are for user-submitted data, not just administrator-edited information and certainly not just configuration. Although I would argue that 'site name' and such belong with configuration options like what theme, the primary purpose of this idea is not to try to force a clean separation of user data versus configuration.
The main goal is to put all data that should be merged between development and staging and between staging and production sites to be stored in a format amenable to version control and merging.
Note to self-Agaric: we need to get on this to get the possibility in Drupal 7.
Approaches:
Allow modules to come with modulename.ini files to store the initial values. This then gets copied to files/config or someplace standard like that. Maybe we should require that we make a non-files directory writable? sites/default/config
Ideally, get/set functions would take a namespace parameter for the module name. Then, when variable_get('myvariable', 'mymodule') is called, Drupal can simply look in mymodule.ini and parse it.
Take over variable_get and variable_set to store all variables this way.
- need to run benchmarks
References
Save Drupal "configuration" to file?
http://drupal.org/node/231971
(this refers to enabled modules etc.)
Switch between Drupal and and your code editor! Create file backups! It's Save-to-File!
http://www.impliedbydesign.com/drupal-module-save-to-file
http://drupal.org/project/savetofile (Drupal 5 only as of 2008 November)
Comments
Post new comment