]> git.pld-linux.org Git - packages/php.git/blame - php-sapi-ini-file.patch
up to 5.5.25
[packages/php.git] / php-sapi-ini-file.patch
CommitLineData
762ec2eb
ER
1--- php-5.5.21/main/php_ini.c 2015-01-21 12:23:27.000000000 +0200
2+++ php-5.5.21/main/php_ini.c 2015-02-25 01:40:21.335354971 +0200
3@@ -378,12 +378,19 @@
c0240cb1 4 }
5 /* }}} */
6
7+static int php_csort(const struct dirent **a, const struct dirent **b)
8+{
9+ return strcmp((*a)->d_name,(*b)->d_name);
10+}
11+
12 /* {{{ php_init_config
13 */
14 int php_init_config(TSRMLS_D)
762ec2eb
ER
15 {
16 char *php_ini_file_name = NULL;
17 char *php_ini_search_path = NULL;
18+ // value for php_ini_loaded_file() to be stored into php_ini_opened_path
19+ char *php_ini_loaded_file = NULL;
20 int php_ini_scanned_path_len;
21 char *open_basedir;
22 int free_ini_search_path = 0;
23@@ -561,8 +568,29 @@
c0240cb1 24 }
25 }
26 }
27+ /* Search (global) php.ini file in search path */
28+ if (!fh.handle.fp) {
29+ fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
30+ if (fh.handle.fp) {
31+ fh.filename = php_ini_opened_path;
762ec2eb
ER
32+
33+ // parse the ini file now
c0240cb1 34+ PG(open_basedir) = open_basedir;
35+ fh.type = ZEND_HANDLE_FP;
36+ zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
c0240cb1 37+ open_basedir = PG(open_basedir);
c0240cb1 38+ PG(open_basedir) = NULL;
39+ fh.handle.fp = NULL;
762ec2eb
ER
40
41- /* Otherwise search for php-%sapi-module-name%.ini file in search path */
42+ // save this for later
43+ php_ini_loaded_file = estrdup(php_ini_opened_path);
44+
c0240cb1 45+ efree(php_ini_opened_path);
46+ fh.filename = php_ini_opened_path = NULL;
47+ }
48+ }
762ec2eb
ER
49+
50+ /* Also search for php-%sapi-module-name%.ini file in search path */
c0240cb1 51 if (!fh.handle.fp) {
762ec2eb
ER
52 const char *fmt = "php-%s.ini";
53 char *ini_fname;
54@@ -572,13 +600,10 @@
55 if (fh.handle.fp) {
c0240cb1 56 fh.filename = php_ini_opened_path;
57 }
762ec2eb
ER
58- }
59
c0240cb1 60- /* If still no ini file found, search for php.ini file in search path */
61- if (!fh.handle.fp) {
62- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
63- if (fh.handle.fp) {
64- fh.filename = php_ini_opened_path;
762ec2eb
ER
65+ // restore previous value, so php_ini_loaded_file() works as expected
66+ if (php_ini_loaded_file) {
67+ php_ini_opened_path = php_ini_loaded_file;
68 }
69 }
c0240cb1 70 }
762ec2eb
ER
71@@ -597,6 +622,10 @@
72
73 {
74 zval tmp;
75+ // use main php.ini if loaded
76+ if (php_ini_loaded_file) {
77+ fh.filename = php_ini_loaded_file;
78+ }
c0240cb1 79
762ec2eb
ER
80 Z_STRLEN(tmp) = strlen(fh.filename);
81 Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
82@@ -630,13 +659,15 @@
c0240cb1 83 zend_llist scanned_ini_list;
84 zend_llist_element *element;
85 int l, total_l = 0;
86+ const char *fmt = "%s:" PHP_CONFIG_FILE_PATH "/%s.d";
2e0e7ed6
AM
87 char *bufpath, *debpath, *endpath;
88 int lenpath;
c0240cb1 89
c0240cb1 90 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
2e0e7ed6 91 memset(&fh2, 0, sizeof(fh2));
b4025702 92
2e0e7ed6
AM
93- bufpath = estrdup(php_ini_scanned_path);
94+ bufpath = emalloc(strlen(php_ini_scanned_path) + strlen(fmt) + strlen(sapi_module.name));
95+ sprintf(bufpath, fmt, php_ini_scanned_path, sapi_module.name);
96 for (debpath = bufpath ; debpath ; debpath=endpath) {
97 endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR);
98 if (endpath) {
762ec2eb 99@@ -649,7 +680,7 @@
2e0e7ed6
AM
100 }
101 lenpath = strlen(debpath);
c0240cb1 102
2e0e7ed6
AM
103- if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) {
104+ if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_csort)) > 0) {
c0240cb1 105
106 for (i = 0; i < ndir; i++) {
2e0e7ed6 107
This page took 0.07731 seconds and 4 git commands to generate.