In Drupal 6 it was easy to configure the port and some other environment variables in settings.php
Since Drupal 7 now has support for multiple environments it has become harder to override these configurations.
We should add this support again to settings.php without changing our flexibility
Drupal 6 :
$conf['apachesolr_host']='localhost';
$conf['apachesolr_port']= '8080';
$conf['apachesolr_path']='/solr/core0';| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 1408844-16.patch | 1.66 KB | nick_vh |
| #15 | 1408844-15.patch | 870 bytes | nick_vh |
| #7 | apachesolr-conf_in_settings-1408844-7.patch | 657 bytes | jrbeeman |
Comments
Comment #0.0
nick_vhUpdated issue summary.
Comment #0.1
nick_vhAdded markup
Comment #1
phoenix commentedHere's an example how we used to set it in the settings.php with the drupal 6 module:
Comment #2
nick_vhAnd the way it should be for D7
Comment #3
nick_vhI was thinking to do this with some array_merge. The module loads these configurations from the settings.php after it loads it from the database. These are getting merged and everything is overridden as expected.
For the long term, or the hard part.. :
It would be perfect if we do not even do a query for the ones that we have set in the settings.php. But that seems a bit overkill for the few times we actually need it. There is already caching in place so I suspect that the first proposal is sufficient
Comment #4
jrbeemanJust noting a use-case we'll want to make sure we handle:
Environment config can be stored in the database or in exportable data via a Feature. My opinion is that the settings.php data should override both database and feature data. @nick_vh, do you agree?
Example:
The following code in settings.php should override this feature:
As a result, my customizations in settings.php could be quite small. Or, I could add entire environment definitions, should I choose to do so.
Comment #5
jrbeemanSorry, I need to clarify that my last comment was on an instance that has the latest patch in #1357588: follow-up for import (needs to be optionally available when ctools is enabled) applied, which allows the config to be exported.
Comment #6
Crell commentedIt feels gross to add a third place (settings.php) that this value can come from (after DB and features export), but I don't think there's a better option given Drupal core's (lack of) support for exported configuration at present. Hopefully D8 will make this better, but for now I cannot think of a less-bad alternative.
Comment #7
jrbeemanHere's a small patch that appears to do the job. Locally, it's working against 7.x-1.x as well as 7.x-1.x with #1357588: follow-up for import (needs to be optionally available when ctools is enabled) applied.
Comment #8
pwolanin commentedSo... what's the use case?
Comment #9
nick_vhTo override settings of any environment in your settings.php. So you can have different environments for testing/staging/production while maintaining the same codebase
Comment #10
pwolanin commentedWell, you could also apply a SQL scrub?
Comment #11
Crell commentedWe want to feature-ize the configuration, because other features (eg Views) will depend on the machine name, but if it's featurized then we cannot override the connection string per-site. That's the problem.
Comment #12
nick_vhjrbeeman, would you be available to write a test for this functionality? It could be as simple as assuming you have an array that could come from a settings.php (you should not create one) and then merge that and test the expected output in the UI.
Comment #13
pwolanin commentedYou could set the global $conf to test?
Comment #14
jrigby commentedWould love to see this feature added. I rebuild dev and staging machines with prod data frequently and this would save me the trouble of reconfiguring the environments.
Comment #15
nick_vhComment #16
nick_vhWith a readme.txt adjustment
Comment #17
nick_vhcommitted to 7.x-1.x
Comment #18
nick_vhcommitted to 6.x-3.x
Comment #19
nick_vhComment #20
alexkb commentedIs Crell's use case solved? : "We want to feature-ize the configuration, because other features (eg Views) will depend on the machine name, but if it's featurized then we cannot override the connection string per-site. That's the problem."By exporting the apache_search_page and not the apachesolr_environment, I still seem to get the feature flagged as "overridden". Does anyone else have this problem?
I ended up re-doing things, and it seems to be working ok now.
Comment #20.0
alexkb commentedUpdated issue summary.
Comment #21
Guillermo.Larrosa commentedIs this supported at this moment on 7.x-1.x ? I can't seem to get it to work, and considering this issue is still open after five years I began to wonder if this actually work.
Comment #22
sjerdoThe correct way to use this is:
Note the conf variable: not apachesolr_environment but apachesolr_environments