summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/source/config.rst3
-rw-r--r--src/snuffleupagus.c10
-rw-r--r--src/tests/config/config_multi1.ini1
-rw-r--r--src/tests/config/config_multi2.ini1
-rw-r--r--src/tests/multi_config.phpt23
5 files changed, 37 insertions, 1 deletions
diff --git a/doc/source/config.rst b/doc/source/config.rst
index b7fa803..3f0115b 100644
--- a/doc/source/config.rst
+++ b/doc/source/config.rst
@@ -6,6 +6,9 @@ Snuffleupagus is using its own format in the file specified by
6the directive ``sp.configuration_file`` (in your ``php.ini`` file), 6the directive ``sp.configuration_file`` (in your ``php.ini`` file),
7like ``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini``. 7like ``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini``.
8 8
9You can use the ``,`` separator to include multiple configuration files :
10``sp.configuration_file=/etc/php/conf.d/snuffleupagus.ini,/etc/php/conf.d/sp_wordpress.ini``
11
9Options are chainable by using dots (``.``) and string parameters 12Options are chainable by using dots (``.``) and string parameters
10**must** be quoted, while booleans and integers aren't. 13**must** be quoted, while booleans and integers aren't.
11 14
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c
index 4f02065..01bc4f6 100644
--- a/src/snuffleupagus.c
+++ b/src/snuffleupagus.c
@@ -154,13 +154,21 @@ PHP_MINFO_FUNCTION(snuffleupagus) {
154static PHP_INI_MH(OnUpdateConfiguration) { 154static PHP_INI_MH(OnUpdateConfiguration) {
155 TSRMLS_FETCH(); 155 TSRMLS_FETCH();
156 156
157 char *config_file = NULL;
158
157 if (!new_value || !new_value->len) { 159 if (!new_value || !new_value->len) {
158 return FAILURE; 160 return FAILURE;
159 } 161 }
160 162
161 if (sp_parse_config(new_value->val) != SUCCESS) { 163 config_file = strtok(new_value->val, ",");
164 if (sp_parse_config(config_file) != SUCCESS) {
162 return FAILURE; 165 return FAILURE;
163 } 166 }
167 while ((config_file = strtok(NULL, ","))) {
168 if (sp_parse_config(config_file) != SUCCESS) {
169 return FAILURE;
170 }
171 }
164 172
165 if (SNUFFLEUPAGUS_G(config).config_random->enable) { 173 if (SNUFFLEUPAGUS_G(config).config_random->enable) {
166 hook_rand(); 174 hook_rand();
diff --git a/src/tests/config/config_multi1.ini b/src/tests/config/config_multi1.ini
new file mode 100644
index 0000000..08ebd72
--- /dev/null
+++ b/src/tests/config/config_multi1.ini
@@ -0,0 +1 @@
sp.disable_function.function("foo").simulation().drop(); \ No newline at end of file
diff --git a/src/tests/config/config_multi2.ini b/src/tests/config/config_multi2.ini
new file mode 100644
index 0000000..487e322
--- /dev/null
+++ b/src/tests/config/config_multi2.ini
@@ -0,0 +1 @@
sp.disable_function.function("bla").simulation().drop(); \ No newline at end of file
diff --git a/src/tests/multi_config.phpt b/src/tests/multi_config.phpt
new file mode 100644
index 0000000..24e69ab
--- /dev/null
+++ b/src/tests/multi_config.phpt
@@ -0,0 +1,23 @@
1--TEST--
2Multiple configuration files
3--SKIPIF--
4<?php if (!extension_loaded("snuffleupagus")) die "skip"; ?>
5--INI--
6sp.configuration_file={PWD}/config/config_multi2.ini,{PWD}/config/config_multi1.ini
7--FILE--
8<?php
9function foo() {
10echo "1\n";
11}
12function bla() {
13echo "2\n";
14}
15foo();
16bla();
17?>
18--EXPECTF--
19[snuffleupagus][0.0.0.0][disabled_function][simulation] The call to the function 'foo' in %s/src/tests/multi_config.php:%d has been disabled.
201
21[snuffleupagus][0.0.0.0][disabled_function][simulation] The call to the function 'bla' in %s/src/tests/multi_config.php:%d has been disabled.
222
23