]> granicus.if.org Git - php/commitdiff
Merge remote-tracking branch 'origin/PHP-5.3' into PHP-5.4
authorXinchen Hui <laruence@php.net>
Mon, 30 Apr 2012 04:15:43 +0000 (12:15 +0800)
committerXinchen Hui <laruence@php.net>
Mon, 30 Apr 2012 04:15:43 +0000 (12:15 +0800)
* origin/PHP-5.3:
  Fixed bug #61546 (functions related to current script failed when chdir() in cli sapi).
  - BFN

Conflicts:
sapi/cli/php_cli.c

1  2 
NEWS
sapi/cli/php_cli.c

diff --cc NEWS
index 057e1aab1bfea21ae527d22fbd82e8f7052b713e,7bb6cc0719c22a9d283ac8fb2a7f4dedfe5fc19b..11251ebf40623e792c6d384d17ab78eb24978fbe
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,15 -1,10 +1,17 @@@
  PHP                                                                        NEWS
  |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 -?? ??? 2012, PHP 5.3.12
 +?? ??? 2012, PHP 5.4.1 RC1
  
 -- CLI SAPI:
 +- CLI Server:
+   . Fixed bug #61546 (functions related to current script failed when chdir() 
+     in cli sapi). (Laruence, reeze.xia@gmail.com)
 +  . Improved performance while sending error page, this also fixed
 +    bug #61785 (Memory leak when access a non-exists file without router).
 +    (Laruence)
 +  . Fixed bug #61461 (missing checks around malloc() calls). (Ilia)
 +  . Implemented FR #60850 (Built in web server does not set 
 +    $_SERVER['SCRIPT_FILENAME'] when using router). (Laruence)
 +  . "Connection: close" instead of "Connection: closed" (Gustavo)
  
  - Core:
    . Fixed missing bound check in iptcparse(). (chris at chiappa.net)
index 801e53ba24a99ae37daba3208f9beaf79edf4f84,f26db43151bf7ab90e3bbbdb695c27e90a00b977..205b9db3feb9c308e2ffe05d313c822574a2bc65
@@@ -650,26 -631,154 +650,26 @@@ static int cli_seek_file_begin(zend_fil
  }
  /* }}} */
  
 -/* {{{ main
 - */
 -#ifdef PHP_CLI_WIN32_NO_CONSOLE
 -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
 -#else
 -int main(int argc, char *argv[])
 -#endif
 +static int do_cli(int argc, char **argv TSRMLS_DC) /* {{{ */
  {
 -      volatile int exit_status = SUCCESS;
        int c;
        zend_file_handle file_handle;
 -/* temporary locals */
 -      int behavior=PHP_MODE_STANDARD;
 +      int behavior = PHP_MODE_STANDARD;
        char *reflection_what = NULL;
 -      int orig_optind=php_optind;
 -      char *orig_optarg=php_optarg;
 +      volatile int request_started = 0;
 +      volatile int exit_status = 0;
 +      char *php_optarg = NULL, *orig_optarg = NULL;
 +      int php_optind = 1, orig_optind = 1;
 +      char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
        char *arg_free=NULL, **arg_excp=&arg_free;
-       char *script_file=NULL;
+       char *script_file=NULL, *translated_path = NULL;
        int interactive=0;
 -      volatile int module_started = 0;
 -      volatile int request_started = 0;
        int lineno = 0;
 -      char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
        const char *param_error=NULL;
        int hide_argv = 0;
 -/* end of temporary locals */
 -#ifdef ZTS
 -      void ***tsrm_ls;
 -#endif
 -#ifdef PHP_CLI_WIN32_NO_CONSOLE
 -      int argc = __argc;
 -      char **argv = __argv;
 -#endif
 -      int ini_entries_len = 0;
 -
 -#if defined(PHP_WIN32) && defined(_DEBUG) && defined(PHP_WIN32_DEBUG_HEAP)
 -      {
 -              int tmp_flag;
 -              _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
 -              _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
 -              _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
 -              _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
 -              _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
 -              _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
 -              tmp_flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
 -              tmp_flag |= _CRTDBG_DELAY_FREE_MEM_DF;
 -              tmp_flag |= _CRTDBG_LEAK_CHECK_DF;
 -
 -              _CrtSetDbgFlag(tmp_flag);
 -      }
 -#endif
 -
 -#ifdef HAVE_SIGNAL_H
 -#if defined(SIGPIPE) && defined(SIG_IGN)
 -      signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
 -                                                              that sockets created via fsockopen()
 -                                                              don't kill PHP if the remote site
 -                                                              closes it.  in apache|apxs mode apache
 -                                                              does that for us!  thies@thieso.net
 -                                                              20000419 */
 -#endif
 -#endif
 -
 -
 -#ifdef ZTS
 -      tsrm_startup(1, 1, 0, NULL);
 -      tsrm_ls = ts_resource(0);
 -#endif
 -
 -      cli_sapi_module.ini_defaults = sapi_cli_ini_defaults;
 -      cli_sapi_module.php_ini_path_override = NULL;
 -      cli_sapi_module.phpinfo_as_text = 1;
 -      sapi_startup(&cli_sapi_module);
 -
 -#ifdef PHP_WIN32
 -      _fmode = _O_BINARY;                     /*sets default for file streams to binary */
 -      setmode(_fileno(stdin), O_BINARY);              /* make the stdio mode be binary */
 -      setmode(_fileno(stdout), O_BINARY);             /* make the stdio mode be binary */
 -      setmode(_fileno(stderr), O_BINARY);             /* make the stdio mode be binary */
 -#endif
  
 -      ini_entries_len = sizeof(HARDCODED_INI)-2;
 -      cli_sapi_module.ini_entries = malloc(sizeof(HARDCODED_INI));
 -      memcpy(cli_sapi_module.ini_entries, HARDCODED_INI, sizeof(HARDCODED_INI));
 -
 -      while ((c = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2))!=-1) {
 -              switch (c) {
 -                      case 'c':
 -                              if (cli_sapi_module.php_ini_path_override) {
 -                                      free(cli_sapi_module.php_ini_path_override);
 -                              }
 -                              cli_sapi_module.php_ini_path_override = strdup(php_optarg);
 -                              break;
 -                      case 'n':
 -                              cli_sapi_module.php_ini_ignore = 1;
 -                              break;
 -                      case 'd': {
 -                              /* define ini entries on command line */
 -                              int len = strlen(php_optarg);
 -                              char *val;
 -
 -                              if ((val = strchr(php_optarg, '='))) {
 -                                      val++;
 -                                      if (!isalnum(*val) && *val != '"' && *val != '\'' && *val != '\0') {
 -                                              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, (val - php_optarg));
 -                                              ini_entries_len += (val - php_optarg);
 -                                              memcpy(cli_sapi_module.ini_entries + ini_entries_len, "\"", 1);
 -                                              ini_entries_len++;
 -                                              memcpy(cli_sapi_module.ini_entries + ini_entries_len, val, len - (val - php_optarg));
 -                                              ini_entries_len += len - (val - php_optarg);
 -                                              memcpy(cli_sapi_module.ini_entries + ini_entries_len, "\"\n\0", sizeof("\"\n\0"));
 -                                              ini_entries_len += sizeof("\n\0\"") - 2;
 -                                      } else {
 -                                              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;
 -      php_optarg = orig_optarg;
 -
 -      cli_sapi_module.executable_location = argv[0];
 -      cli_sapi_module.additional_functions = additional_functions;
 -
 -      /* startup after we get the above ini override se we get things right */
 -      if (cli_sapi_module.startup(&cli_sapi_module)==FAILURE) {
 -              /* there is no way to see if we must call zend_ini_deactivate()
 -               * since we cannot check if EG(ini_directives) has been initialised
 -               * because the executor's constructor does not set initialize it.
 -               * Apart from that there seems no need for zend_ini_deactivate() yet.
 -               * So we goto out_err.*/
 -              exit_status = 1;
 -              goto out_err;
 -      }
 -      module_started = 1;
 -
 -      zend_first_try {
 +      zend_try {
 +      
                CG(in_compilation) = 0; /* not initialized but needed for several options */
                EG(uninitialized_zval_ptr) = NULL;
  
                SG(request_info).argc=argc-php_optind+1;
                arg_excp = argv+php_optind-1;
                arg_free = argv[php_optind-1];
-               SG(request_info).path_translated = (char*)file_handle.filename;
 -              SG(request_info).path_translated = translated_path? translated_path : file_handle.filename;
 -              argv[php_optind-1] = file_handle.filename;
++              SG(request_info).path_translated = translated_path? translated_path: (char*)file_handle.filename;
 +              argv[php_optind-1] = (char*)file_handle.filename;
                SG(request_info).argv=argv+php_optind-1;
  
                if (php_request_startup(TSRMLS_C)==FAILURE) {