php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #68022
Patch master-fpm-multiple-include.patch revision 2014-09-15 22:27 UTC by manuel-php at mausz dot at

Patch master-fpm-multiple-include.patch for FPM related Bug #68022

Patch version 2014-09-15 22:27 UTC

Return to Bug #68022 | Download this patch
Patch Revisions:

Developer: manuel-php@mausz.at

diff -Naur php-src.orig/sapi/fpm/fpm/fpm_conf.c php-src/sapi/fpm/fpm/fpm_conf.c
--- php-src.orig/sapi/fpm/fpm/fpm_conf.c.orig	2014-09-15 22:15:46.603108914 +0200
+++ php-src/sapi/fpm/fpm/fpm_conf.c	2014-09-15 22:18:25.709715024 +0200
@@ -86,7 +86,6 @@
 static int ini_recursion = 0;
 static char *ini_filename = NULL;
 static int ini_lineno = 0;
-static char *ini_include = NULL;
 
 /* 
  * Please keep the same order as in fpm_conf.h and in php-fpm.conf.in
@@ -1247,7 +1246,7 @@
 #ifdef HAVE_GLOB
 	glob_t g;
 #endif
-	int i;
+	int i, current_lineno = ini_lineno;
 
 	if (!inc || !arg) return;
 	if (*error) return; /* We got already an error. Switch to the end. */
@@ -1259,12 +1258,12 @@
 		if ((i = glob(inc, GLOB_ERR | GLOB_MARK | GLOB_NOSORT, NULL, &g)) != 0) {
 #ifdef GLOB_NOMATCH
 			if (i == GLOB_NOMATCH) {
-				zlog(ZLOG_WARNING, "Nothing matches the include pattern '%s' from %s at line %d.", inc, filename, ini_lineno);
+				zlog(ZLOG_WARNING, "Nothing matches the include pattern '%s' from %s at line %d.", inc, filename, current_lineno);
 				efree(filename);
 				return;
 			} 
 #endif /* GLOB_NOMATCH */
-			zlog(ZLOG_ERROR, "Unable to globalize '%s' (ret=%d) from %s at line %d.", inc, i, filename, ini_lineno);
+			zlog(ZLOG_ERROR, "Unable to globalize '%s' (ret=%d) from %s at line %d.", inc, i, filename, current_lineno);
 			*error = 1;
 			efree(filename);
 			return;
@@ -1275,7 +1274,7 @@
 			if (len < 1) continue;
 			if (g.gl_pathv[i][len - 1] == '/') continue; /* don't parse directories */
 			if (0 > fpm_conf_load_ini_file(g.gl_pathv[i] TSRMLS_CC)) {
-				zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, ini_lineno);
+				zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", g.gl_pathv[i], filename, current_lineno);
 				*error = 1;
 				efree(filename);
 				return;
@@ -1285,7 +1284,7 @@
 	}
 #else /* HAVE_GLOB */
 	if (0 > fpm_conf_load_ini_file(inc TSRMLS_CC)) {
-		zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", inc, filename, ini_lineno);
+		zlog(ZLOG_ERROR, "Unable to include %s from %s at line %d", inc, filename, current_lineno);
 		*error = 1;
 		efree(filename);
 		return;
@@ -1347,12 +1346,12 @@
 	}
 
 	if (!strcmp(Z_STRVAL_P(name), "include")) {
-		if (ini_include) {
-			zlog(ZLOG_ERROR, "[%s:%d] two includes at the same time !", ini_filename, ini_lineno);
-			*error = 1;
-			return;
-		}
-		ini_include = strdup(Z_STRVAL_P(value));
+		char *tmp = strdup(Z_STRVAL_P(value));
+		int save_ini_lineno = ini_lineno;
+		fpm_evaluate_full_path(&tmp, NULL, NULL, 0);
+		fpm_conf_ini_parser_include(tmp, error TSRMLS_CC);
+		ini_lineno = save_ini_lineno;
+		free(tmp);
 		return;
 	}
 
@@ -1530,26 +1529,11 @@
 		tmp = zend_parse_ini_string(buf, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t)fpm_conf_ini_parser, &error TSRMLS_CC);
 		ini_filename = filename;
 		if (error || tmp == FAILURE) {
-			if (ini_include) free(ini_include);
 			ini_recursion--;
 			close(fd);
 			free(buf);
 			return -1;
 		}
-		if (ini_include) {
-			char *tmp = ini_include;
-			ini_include = NULL;
-			fpm_evaluate_full_path(&tmp, NULL, NULL, 0);
-			fpm_conf_ini_parser_include(tmp, &error TSRMLS_CC);
-			if (error) {
-				free(tmp);
-				ini_recursion--;
-				close(fd);
-				free(buf);
-				return -1;
-			}
-			free(tmp);
-		}
 	}
 	free(buf);
 
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Jan 21 02:01:23 2020 UTC