dmitry Tue Sep 19 20:33:12 2006 UTC
Modified files: (Branch: PHP_5_2)
/php-src/main SAPI.h SAPI.c php_ini.c
/php-src NEWS
/ZendEngine2 zend_ini.h zend_ini_parser.y zend_ini_scanner.h
zend_ini_scanner.l
/php-src/sapi/cgi cgi_main.c
/php-src/sapi/cli php_cli.c
Log:
MFH: Fixed mess with CGI/CLI -d command line option (now it works with cgi;
constants are working exactly like in php.ini; with FastCGI -d affects all
requests).
http://cvs.php.net/viewvc.cgi/php-src/main/SAPI.h?r1=1.114.2.1&r2=1.114.2.1.2.1&diff_format=u
Index: php-src/main/SAPI.h
diff -u php-src/main/SAPI.h:1.114.2.1 php-src/main/SAPI.h:1.114.2.1.2.1
--- php-src/main/SAPI.h:1.114.2.1 Sun Jan 1 12:50:17 2006
+++ php-src/main/SAPI.h Tue Sep 19 20:33:11 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: SAPI.h,v 1.114.2.1 2006/01/01 12:50:17 sniper Exp $ */
+/* $Id: SAPI.h,v 1.114.2.1.2.1 2006/09/19 20:33:11 dmitry Exp $ */
#ifndef SAPI_H
#define SAPI_H
@@ -257,6 +257,8 @@
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
+
+ char *ini_entries;
};
http://cvs.php.net/viewvc.cgi/php-src/main/SAPI.c?r1=1.202.2.7.2.1&r2=1.202.2.7.2.2&diff_format=u
Index: php-src/main/SAPI.c
diff -u php-src/main/SAPI.c:1.202.2.7.2.1 php-src/main/SAPI.c:1.202.2.7.2.2
--- php-src/main/SAPI.c:1.202.2.7.2.1 Wed May 10 21:19:32 2006
+++ php-src/main/SAPI.c Tue Sep 19 20:33:11 2006
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: SAPI.c,v 1.202.2.7.2.1 2006/05/10 21:19:32 rasmus Exp $ */
+/* $Id: SAPI.c,v 1.202.2.7.2.2 2006/09/19 20:33:11 dmitry Exp $ */
#include <ctype.h>
#include <sys/stat.h>
@@ -76,6 +76,7 @@
SAPI_API void sapi_startup(sapi_module_struct *sf)
{
+ sf->ini_entries = NULL;
sapi_module = *sf;
#ifdef ZTS
http://cvs.php.net/viewvc.cgi/php-src/main/php_ini.c?r1=1.136.2.4.2.3&r2=1.136.2.4.2.4&diff_format=u
Index: php-src/main/php_ini.c
diff -u php-src/main/php_ini.c:1.136.2.4.2.3
php-src/main/php_ini.c:1.136.2.4.2.4
--- php-src/main/php_ini.c:1.136.2.4.2.3 Tue Sep 5 11:54:15 2006
+++ php-src/main/php_ini.c Tue Sep 19 20:33:11 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ini.c,v 1.136.2.4.2.3 2006/09/05 11:54:15 edink Exp $ */
+/* $Id: php_ini.c,v 1.136.2.4.2.4 2006/09/19 20:33:11 dmitry Exp $ */
#include "php.h"
#include "ext/standard/info.h"
@@ -529,6 +529,11 @@
zend_llist_destroy(&scanned_ini_list);
}
}
+
+ if (sapi_module.ini_entries) {
+ zend_parse_ini_string(sapi_module.ini_entries, 1,
php_config_ini_parser_cb, &extension_lists);
+ }
+
return SUCCESS;
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.257&r2=1.2027.2.547.2.258&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.257 php-src/NEWS:1.2027.2.547.2.258
--- php-src/NEWS:1.2027.2.547.2.257 Tue Sep 19 15:45:22 2006
+++ php-src/NEWS Tue Sep 19 20:33:12 2006
@@ -1,6 +1,9 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Sep 2006, PHP 5.2.0
+- Fixed mess with CGI/CLI -d option (now it works with cgi; constants are
+ working exactly like in php.ini; with FastCGI -d affects all requests).
+ (Dmitry)
- Fixed bug #38844 (curl_easy_strerror() is defined only since cURL 7.12.0).
(Tony)
- Fixed bug #38574 (missing curl constants and improper constant detection).
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini.h?r1=1.34.2.1&r2=1.34.2.1.2.1&diff_format=u
Index: ZendEngine2/zend_ini.h
diff -u ZendEngine2/zend_ini.h:1.34.2.1 ZendEngine2/zend_ini.h:1.34.2.1.2.1
--- ZendEngine2/zend_ini.h:1.34.2.1 Wed Jan 4 23:53:04 2006
+++ ZendEngine2/zend_ini.h Tue Sep 19 20:33:12 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ini.h,v 1.34.2.1 2006/01/04 23:53:04 andi Exp $ */
+/* $Id: zend_ini.h,v 1.34.2.1.2.1 2006/09/19 20:33:12 dmitry Exp $ */
#ifndef ZEND_INI_H
#define ZEND_INI_H
@@ -193,6 +193,7 @@
typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, int
callback_type, void *arg);
BEGIN_EXTERN_C()
ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool
unbuffered_errors, zend_ini_parser_cb_t ini_parser_cb, void *arg);
+ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors,
zend_ini_parser_cb_t ini_parser_cb, void *arg);
END_EXTERN_C()
#define ZEND_INI_PARSER_ENTRY 1
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini_parser.y?r1=1.41.2.2&r2=1.41.2.2.2.1&diff_format=u
Index: ZendEngine2/zend_ini_parser.y
diff -u ZendEngine2/zend_ini_parser.y:1.41.2.2
ZendEngine2/zend_ini_parser.y:1.41.2.2.2.1
--- ZendEngine2/zend_ini_parser.y:1.41.2.2 Wed Apr 12 09:51:54 2006
+++ ZendEngine2/zend_ini_parser.y Tue Sep 19 20:33:12 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ini_parser.y,v 1.41.2.2 2006/04/12 09:51:54 dmitry Exp $ */
+/* $Id: zend_ini_parser.y,v 1.41.2.2.2.1 2006/09/19 20:33:12 dmitry Exp $ */
#define DEBUG_CFG_PARSER 0
#include "zend.h"
@@ -157,10 +157,14 @@
TSRMLS_FETCH();
currently_parsed_filename = zend_ini_scanner_get_filename(TSRMLS_C);
- error_buf_len = 128+strlen(currently_parsed_filename); /* should be
more than enough */
- error_buf = (char *) emalloc(error_buf_len);
+ if (currently_parsed_filename) {
+ error_buf_len = 128+strlen(currently_parsed_filename); /*
should be more than enough */
+ error_buf = (char *) emalloc(error_buf_len);
- sprintf(error_buf, "Error parsing %s on line %d\n",
currently_parsed_filename, zend_ini_scanner_get_lineno(TSRMLS_C));
+ sprintf(error_buf, "Error parsing %s on line %d\n",
currently_parsed_filename, zend_ini_scanner_get_lineno(TSRMLS_C));
+ } else {
+ error_buf = estrdup("Invalid configuration directive\n");
+ }
if (CG(ini_parser_unbuffered_errors)) {
#ifdef PHP_WIN32
@@ -202,6 +206,29 @@
}
+ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors,
zend_ini_parser_cb_t ini_parser_cb, void *arg)
+{
+ zend_ini_parser_param ini_parser_param;
+ TSRMLS_FETCH();
+
+ ini_parser_param.ini_parser_cb = ini_parser_cb;
+ ini_parser_param.arg = arg;
+
+ CG(ini_parser_param) = &ini_parser_param;
+ if (zend_ini_prepare_string_for_scanning(str TSRMLS_CC)==FAILURE) {
+ return FAILURE;
+ }
+
+ CG(ini_parser_unbuffered_errors) = unbuffered_errors;
+
+ if (ini_parse(TSRMLS_C)) {
+ return SUCCESS;
+ } else {
+ return FAILURE;
+ }
+}
+
+
%}
%pure_parser
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini_scanner.h?r1=1.14.2.1&r2=1.14.2.1.2.1&diff_format=u
Index: ZendEngine2/zend_ini_scanner.h
diff -u ZendEngine2/zend_ini_scanner.h:1.14.2.1
ZendEngine2/zend_ini_scanner.h:1.14.2.1.2.1
--- ZendEngine2/zend_ini_scanner.h:1.14.2.1 Wed Jan 4 23:53:04 2006
+++ ZendEngine2/zend_ini_scanner.h Tue Sep 19 20:33:12 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ini_scanner.h,v 1.14.2.1 2006/01/04 23:53:04 andi Exp $ */
+/* $Id: zend_ini_scanner.h,v 1.14.2.1.2.1 2006/09/19 20:33:12 dmitry Exp $ */
#ifndef _ZEND_INI_SCANNER_H
#define _ZEND_INI_SCANNER_H
@@ -26,6 +26,7 @@
int zend_ini_scanner_get_lineno(TSRMLS_D);
char *zend_ini_scanner_get_filename(TSRMLS_D);
int zend_ini_open_file_for_scanning(zend_file_handle *fh TSRMLS_DC);
+int zend_ini_prepare_string_for_scanning(char *str TSRMLS_DC);
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC);
int ini_lex(zval *ini_lval TSRMLS_DC);
END_EXTERN_C()
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_ini_scanner.l?r1=1.41.2.2&r2=1.41.2.2.2.1&diff_format=u
Index: ZendEngine2/zend_ini_scanner.l
diff -u ZendEngine2/zend_ini_scanner.l:1.41.2.2
ZendEngine2/zend_ini_scanner.l:1.41.2.2.2.1
--- ZendEngine2/zend_ini_scanner.l:1.41.2.2 Tue Jan 17 19:56:25 2006
+++ ZendEngine2/zend_ini_scanner.l Tue Sep 19 20:33:12 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_ini_scanner.l,v 1.41.2.2 2006/01/17 19:56:25 iliaa Exp $ */
+/* $Id: zend_ini_scanner.l,v 1.41.2.2.2.1 2006/09/19 20:33:12 dmitry Exp $ */
#define yyleng SCNG(yy_leng)
#define yytext SCNG(yy_text)
@@ -83,6 +83,17 @@
}
+int zend_ini_prepare_string_for_scanning(char *str TSRMLS_DC)
+{
+ int len = strlen(str);
+
+ yyin = NULL;
+ yy_scan_buffer(str, len + 2 TSRMLS_CC);
+ ini_filename = NULL;
+ return SUCCESS;
+}
+
+
void zend_ini_close_file(zend_file_handle *fh TSRMLS_DC)
{
zend_stream_close(fh);
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/cgi_main.c?r1=1.267.2.15.2.10&r2=1.267.2.15.2.11&diff_format=u
Index: php-src/sapi/cgi/cgi_main.c
diff -u php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.10
php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.11
--- php-src/sapi/cgi/cgi_main.c:1.267.2.15.2.10 Thu Aug 31 13:11:58 2006
+++ php-src/sapi/cgi/cgi_main.c Tue Sep 19 20:33:12 2006
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: cgi_main.c,v 1.267.2.15.2.10 2006/08/31 13:11:58 dmitry Exp $ */
+/* $Id: cgi_main.c,v 1.267.2.15.2.11 2006/09/19 20:33:12 dmitry Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -919,21 +919,6 @@
}
/* }}} */
-static void define_command_line_ini_entry(char *arg)
-{
- char *name, *value;
-
- name = arg;
- value = strchr(arg, '=');
- if (value) {
- *value = 0;
- value++;
- } else {
- value = "1";
- }
- zend_alter_ini_entry(name, strlen(name) + 1, value, strlen(value),
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-}
-
#if PHP_FASTCGI
/**
* Clean up child processes upon exit
@@ -987,6 +972,7 @@
int orig_optind = php_optind;
char *orig_optarg = php_optarg;
char *script_file = NULL;
+ int ini_entries_len = 0;
#if FORCE_CGI_REDIRECT
long force_redirect = 1;
char *redirect_status_env = NULL;
@@ -1076,6 +1062,23 @@
case 'n':
cgi_sapi_module.php_ini_ignore = 1;
break;
+ case 'd': {
+ /* define ini entries on command line */
+ int len = strlen(php_optarg);
+
+ if (strchr(php_optarg, '=')) {
+ cgi_sapi_module.ini_entries =
realloc(cgi_sapi_module.ini_entries, ini_entries_len + len + sizeof("\n\0"));
+ memcpy(cgi_sapi_module.ini_entries +
ini_entries_len, php_optarg, len);
+ memcpy(cgi_sapi_module.ini_entries +
ini_entries_len + len, "\n\0", sizeof("\n\0"));
+ ini_entries_len += len + sizeof("\n\0")
- 2;
+ } else {
+ cgi_sapi_module.ini_entries =
realloc(cgi_sapi_module.ini_entries, ini_entries_len + len + sizeof("=1\n\0"));
+ memcpy(cgi_sapi_module.ini_entries +
ini_entries_len, php_optarg, len);
+ memcpy(cgi_sapi_module.ini_entries +
ini_entries_len + len, "=1\n\0", sizeof("=1\n\0"));
+ ini_entries_len += len +
sizeof("=1\n\0") - 2;
+ }
+ break;
+ }
#if PHP_FASTCGI
#ifndef PHP_WIN32
/* if we're started on command line, check to see if
@@ -1378,9 +1381,6 @@
case 'C': /* don't chdir to the script
directory */
SG(options) |=
SAPI_OPTION_NO_CHDIR;
break;
- case 'd': /* define ini entries on command line
*/
-
define_command_line_ini_entry(php_optarg);
- break;
case 'e': /* enable extended info output */
CG(extended_info) = 1;
@@ -1702,6 +1702,9 @@
if (cgi_sapi_module.php_ini_path_override) {
free(cgi_sapi_module.php_ini_path_override);
}
+ if (cgi_sapi_module.ini_entries) {
+ free(cgi_sapi_module.ini_entries);
+ }
} zend_catch {
exit_status = 255;
} zend_end_try();
http://cvs.php.net/viewvc.cgi/php-src/sapi/cli/php_cli.c?r1=1.129.2.13.2.8&r2=1.129.2.13.2.9&diff_format=u
Index: php-src/sapi/cli/php_cli.c
diff -u php-src/sapi/cli/php_cli.c:1.129.2.13.2.8
php-src/sapi/cli/php_cli.c:1.129.2.13.2.9
--- php-src/sapi/cli/php_cli.c:1.129.2.13.2.8 Fri Sep 15 08:18:36 2006
+++ php-src/sapi/cli/php_cli.c Tue Sep 19 20:33:12 2006
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_cli.c,v 1.129.2.13.2.8 2006/09/15 08:18:36 tony2001 Exp $ */
+/* $Id: php_cli.c,v 1.129.2.13.2.9 2006/09/19 20:33:12 dmitry Exp $ */
#include "php.h"
#include "php_globals.h"
@@ -106,6 +106,15 @@
#define PHP_MODE_REFLECTION_CLASS 9
#define PHP_MODE_REFLECTION_EXTENSION 10
+#define HARDCODED_INI \
+ "html_errors=0\n" \
+ "register_argc_argv=1\n" \
+ "implicit_flush=1\n" \
+ "output_buffering=0\n" \
+ "max_execution_time=0\n" \
+ "max_input_time=-1\n"
+
+
static char *php_optarg = NULL;
static int php_optind = 1;
#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
@@ -342,10 +351,6 @@
zend_hash_update(configuration_hash, name, sizeof(name), tmp,
sizeof(zval), (void**)&entry);\
Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry))
-/* hard coded ini settings must be set in main() */
-#define INI_HARDCODED(name,value)\
- zend_alter_ini_entry(name, sizeof(name), value, strlen(value),
PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
-
static void sapi_cli_ini_defaults(HashTable *configuration_hash)
{
zval *tmp, *entry;
@@ -451,29 +456,6 @@
}
/* }}} */
-static void define_command_line_ini_entry(char *arg TSRMLS_DC)
-{
- char *name, *value;
-
- name = arg;
- value = strchr(arg, '=');
- if (value) {
- *value = 0;
- value++;
- } else {
- value = "1";
- }
-
- if (!strcasecmp(name, "extension")) { /* load function module */
- zval extension, zval;
- ZVAL_STRING(&extension, value, 0);
- php_dl(&extension, MODULE_PERSISTENT, &zval, 1 TSRMLS_CC);
- } else {
- zend_alter_ini_entry(name, strlen(name)+1, value,
strlen(value), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
- }
-}
-
-
static php_stream *s_in_process = NULL;
static void cli_register_file_handles(TSRMLS_D)
@@ -602,6 +584,7 @@
int argc = __argc;
char **argv = __argv;
#endif
+ int ini_entries_len = 0;
#if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP)
{
@@ -646,6 +629,10 @@
setmode(_fileno(stderr), O_BINARY); /* make the stdio mode
be binary */
#endif
+ ini_entries_len = strlen(HARDCODED_INI);
+ cli_sapi_module.ini_entries = malloc(ini_entries_len+2);
+ memcpy(cli_sapi_module.ini_entries, HARDCODED_INI, ini_entries_len+1);
+ cli_sapi_module.ini_entries[ini_entries_len+1] = 0;
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind,
0))!=-1) {
switch (c) {
@@ -655,6 +642,23 @@
case 'n':
cli_sapi_module.php_ini_ignore = 1;
break;
+ case 'd': {
+ /* define ini entries on command line */
+ int len = strlen(php_optarg);
+
+ if (strchr(php_optarg, '=')) {
+ cli_sapi_module.ini_entries =
realloc(cli_sapi_module.ini_entries, ini_entries_len + len + sizeof("\n\0"));
+ memcpy(cli_sapi_module.ini_entries +
ini_entries_len, php_optarg, len);
+ memcpy(cli_sapi_module.ini_entries +
ini_entries_len + len, "\n\0", sizeof("\n\0"));
+ ini_entries_len += len + sizeof("\n\0")
- 2;
+ } else {
+ cli_sapi_module.ini_entries =
realloc(cli_sapi_module.ini_entries, ini_entries_len + len + sizeof("=1\n\0"));
+ memcpy(cli_sapi_module.ini_entries +
ini_entries_len, php_optarg, len);
+ memcpy(cli_sapi_module.ini_entries +
ini_entries_len + len, "=1\n\0", sizeof("=1\n\0"));
+ ini_entries_len += len +
sizeof("=1\n\0") - 2;
+ }
+ break;
+ }
}
}
php_optind = orig_optind;
@@ -683,7 +687,6 @@
module_started = 1;
zend_first_try {
- zend_uv.html_errors = 0; /* tell the engine we're in non-html
mode */
CG(in_compilation) = 0; /* not initialized but needed for
several options */
EG(uninitialized_zval_ptr) = NULL;
@@ -693,21 +696,9 @@
goto out_err;
}
- /* here is the place for hard coded defaults which cannot be
overwritten in the ini file */
- INI_HARDCODED("register_argc_argv", "1");
- INI_HARDCODED("html_errors", "0");
- INI_HARDCODED("implicit_flush", "1");
- INI_HARDCODED("output_buffering", "0");
- INI_HARDCODED("max_execution_time", "0");
- INI_HARDCODED("max_input_time", "-1");
-
while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg,
&php_optind, 0)) != -1) {
switch (c) {
- case 'd': /* define ini entries on command line */
- define_command_line_ini_entry(php_optarg
TSRMLS_CC);
- break;
-
case 'h': /* help & quit */
case '?':
if (php_request_startup(TSRMLS_C)==FAILURE) {
@@ -1260,6 +1251,10 @@
if (cli_sapi_module.php_ini_path_override) {
free(cli_sapi_module.php_ini_path_override);
}
+ if (cli_sapi_module.ini_entries) {
+ free(cli_sapi_module.ini_entries);
+ }
+
if (module_started) {
php_module_shutdown(TSRMLS_C);
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php