]> git.pld-linux.org Git - packages/php.git/blob - php-sapi-ini-file.patch
PHP 5.6.13 (03 Sep 2015)
[packages/php.git] / php-sapi-ini-file.patch
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 @@
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)
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 @@
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;
32 +
33 +                               // parse the ini file now
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);
37 +                               open_basedir = PG(open_basedir);
38 +                               PG(open_basedir) = NULL;
39 +                               fh.handle.fp = NULL;
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 +
45 +                               efree(php_ini_opened_path);
46 +                               fh.filename = php_ini_opened_path = NULL;
47 +                       }
48 +               }
49 +
50 +               /* Also search for php-%sapi-module-name%.ini file in search path */
51                 if (!fh.handle.fp) {
52                         const char *fmt = "php-%s.ini";
53                         char *ini_fname;
54 @@ -572,13 +600,10 @@
55                         if (fh.handle.fp) {
56                                 fh.filename = php_ini_opened_path;
57                         }
58 -               }
59  
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;
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                 }
70         }
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 +                       }
79  
80                         Z_STRLEN(tmp) = strlen(fh.filename);
81                         Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp));
82 @@ -630,13 +659,15 @@
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";
87                 char *bufpath, *debpath, *endpath;
88                 int lenpath;
89  
90                 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
91                 memset(&fh2, 0, sizeof(fh2));
92  
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) {
99 @@ -649,7 +680,7 @@
100                         }
101                         lenpath = strlen(debpath);
102  
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) {
105  
106                                 for (i = 0; i < ndir; i++) {
107  
This page took 0.034583 seconds and 3 git commands to generate.