]> git.pld-linux.org Git - packages/php.git/blob - php-sapi-ini-file.patch
- force expat due to http://bugs.php.net/bug.php?id=45996
[packages/php.git] / php-sapi-ini-file.patch
1 --- php-5.2.7/main/php_ini.c    2008-08-14 19:34:30.000000000 +0300
2 +++ php-5.2.7-inidir/main/php_ini.c     2008-12-05 12:53:24.747685251 +0200
3 @@ -474,6 +474,24 @@
4                                 }
5                         }
6                 }
7 +               /* Search (global) php.ini file in search path */
8 +               if (!fh.handle.fp) {
9 +                       fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
10 +                       if (fh.handle.fp) {
11 +                               fh.filename = php_ini_opened_path;
12 +                               PG(safe_mode) = safe_mode_state;
13 +                               PG(open_basedir) = open_basedir;
14 +                               fh.type = ZEND_HANDLE_FP;
15 +                               zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
16 +                               safe_mode_state = PG(safe_mode);
17 +                               open_basedir = PG(open_basedir);
18 +                               PG(safe_mode) = 0;
19 +                               PG(open_basedir) = NULL;
20 +                               fh.handle.fp = NULL;
21 +                               efree(php_ini_opened_path);
22 +                               fh.filename = php_ini_opened_path = NULL;
23 +                       }
24 +               }
25  
26                 /* Otherwise search for php-%sapi-module-name%.ini file in search path */
27                 if (!fh.handle.fp) {
28 @@ -486,14 +504,6 @@
29                                 fh.filename = php_ini_opened_path;
30                         }
31                 }
32 -
33 -               /* If still no ini file found, search for php.ini file in search path */
34 -               if (!fh.handle.fp) {
35 -                       fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC);
36 -                       if (fh.handle.fp) {
37 -                               fh.filename = php_ini_opened_path;
38 -                       }
39 -               }
40         }
41  
42         if (free_ini_search_path) {
43 @@ -533,9 +543,13 @@
44         /* Scan and parse any .ini files found in scan path if path not empty. */
45         if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) {
46                 struct dirent **namelist;
47 -               int ndir, i;
48 +               int ndir, i, found = 0;
49 +               const char *fmt = PHP_CONFIG_FILE_PATH "/%s.d";
50 +               char *sapi_scan_dir = emalloc(strlen(fmt) + strlen(sapi_module.name));
51 +               sprintf(sapi_scan_dir, fmt, sapi_module.name);
52  
53                 if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) {
54 +                       found += ndir;
55                         for (i = 0; i < ndir; i++) {
56                                 /* check for a .ini extension */
57                                 if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
58 @@ -556,6 +570,35 @@
59                                                         /* Here, add it to the list of ini files read */
60                                                         l = strlen(ini_file);
61                                                         total_l += l + 2;
62 +                                                       p = estrndup(ini_file, l); 
63 +                                                       zend_llist_add_element(&scanned_ini_list, &p);
64 +                                               }
65 +                                       }
66 +                               }
67 +                               free(namelist[i]);
68 +                       }
69 +                       free(namelist);
70 +               }
71 +
72 +               if ((ndir = php_scandir(sapi_scan_dir, &namelist, 0, php_alphasort)) > 0) {
73 +                       found += ndir;
74 +
75 +                       for (i = 0; i < ndir; i++) {
76 +                               /* check for a .ini extension */
77 +                               if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) {
78 +                                       free(namelist[i]);
79 +                                       continue;
80 +                               }
81 +                               snprintf(ini_file, MAXPATHLEN, "%s%c%s", sapi_scan_dir, DEFAULT_SLASH, namelist[i]->d_name);
82 +                               if (VCWD_STAT(ini_file, &sb) == 0) {
83 +                                       if (S_ISREG(sb.st_mode)) {
84 +                                               if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
85 +                                                       fh.filename = ini_file;
86 +                                                       fh.type = ZEND_HANDLE_FP;
87 +                                                       zend_parse_ini_file(&fh, 1, php_config_ini_parser_cb, &extension_lists);
88 +                                                       /* Here, add it to the list of ini files read */
89 +                                                       l = strlen(ini_file);
90 +                                                       total_l += l + 2;
91                                                         p = estrndup(ini_file, l);
92                                                         zend_llist_add_element(&scanned_ini_list, &p);
93                                                 }
94 @@ -564,8 +607,11 @@
95                                 free(namelist[i]);
96                         }
97                         free(namelist);
98 +               }
99 +               efree(sapi_scan_dir);
100  
101 -                       /*
102 +               if (found) {
103 +                       /* 
104                          * Don't need an extra byte for the \0 in this malloc as the last
105                          * element will not get a trailing , which gives us the byte for the \0
106                          */
This page took 0.03211 seconds and 3 git commands to generate.