]> TLD Linux GIT Repositories - packages/php.git/blob - php-sapi-ini-file.patch
- updated to 5.6.17
[packages/php.git] / php-sapi-ini-file.patch
1 --- php-5.4.0RC3/main/php_ini.c~        2011-12-10 03:35:27.000000000 +0200
2 +++ php-5.4.0RC3/main/php_ini.c 2011-12-10 03:36:08.930154336 +0200
3 @@ -358,6 +358,11 @@
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 @@ -480,6 +485,24 @@
16                                 }
17                         }
18                 }
19 +               /* Search (global) php.ini file in search path */
20 +               if (!fh.handle.fp) {
21 +                       fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
22 +                       if (fh.handle.fp) {
23 +                               fh.filename = php_ini_opened_path;
24 +                               //PG(safe_mode) = safe_mode_state;
25 +                               PG(open_basedir) = open_basedir;
26 +                               fh.type = ZEND_HANDLE_FP;
27 +                               zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC);
28 +                               //safe_mode_state = PG(safe_mode);
29 +                               open_basedir = PG(open_basedir);
30 +                               //PG(safe_mode) = 0;
31 +                               PG(open_basedir) = NULL;
32 +                               fh.handle.fp = NULL;
33 +                               efree(php_ini_opened_path);
34 +                               fh.filename = php_ini_opened_path = NULL;
35 +                       }
36 +               }
37  
38                 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
39                 if (!fh.handle.fp) {
40 @@ -492,14 +515,6 @@
41                                 fh.filename = php_ini_opened_path;
42                         }
43                 }
44 -
45 -               /* If still no ini file found, search for php.ini file in search path */
46 -               if (!fh.handle.fp) {
47 -                       fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
48 -                       if (fh.handle.fp) {
49 -                               fh.filename = php_ini_opened_path;
50 -                       }
51 -               }
52         }
53  
54         if (free_ini_search_path) {
55 @@ -645,13 +645,15 @@ int php_init_config(TSRMLS_D)
56                 zend_llist scanned_ini_list;
57                 zend_llist_element *element;
58                 int l, total_l = 0;
59 +               const char *fmt = "%s:" PHP_CONFIG_FILE_PATH "/%s.d";
60                 char *bufpath, *debpath, *endpath;
61                 int lenpath;
62  
63                 zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
64                 memset(&fh2, 0, sizeof(fh2));
65  
66 -               bufpath = estrdup(php_ini_scanned_path);
67 +               bufpath = emalloc(strlen(php_ini_scanned_path) + strlen(fmt) + strlen(sapi_module.name));
68 +               sprintf(bufpath, fmt, php_ini_scanned_path, sapi_module.name);
69                 for (debpath = bufpath ; debpath ; debpath=endpath) {
70                         endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR);
71                         if (endpath) {
72 @@ -664,7 +666,7 @@ int php_init_config(TSRMLS_D)
73                         }
74                         lenpath = strlen(debpath);
75  
76 -                       if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) {
77 +                       if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_csort)) > 0) {
78  
79                                 for (i = 0; i < ndir; i++) {
80  
81