Skip to content

Commit

Permalink
Fixed bug #71234 (INI files are loaded even invoked as phpdbg -n --ve…
Browse files Browse the repository at this point in the history
…rsion)
  • Loading branch information
bwoebi committed Oct 16, 2016
1 parent e93eaee commit d82da7d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 34 deletions.
3 changes: 2 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ PHP NEWS
. Add -s command line option / stdin command for reading script from stdin.
(Bob)
. Ignore non-executable opcodes in line mode of phpdbg_end_oplog(). (Bob)
. Fixed bug #70776 (Simple SIGINT does not have any effect). (Bob)
. Fixed bug #70776 (Simple SIGINT does not have any effect with -rr). (Bob)
. Fixed bug #71234 (INI files are loaded even invoked as -n --version). (Bob)

- Session:
. Fixed bug #73273 (session_unset() empties values from all variables in which
Expand Down
82 changes: 49 additions & 33 deletions sapi/phpdbg/phpdbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ int main(int argc, char **argv) /* {{{ */
int exit_status;
char *read_from_stdin = NULL;
zend_string *backup_phpdbg_compile = NULL;
zend_bool show_help = 0, show_version = 0;

#ifndef _WIN32
struct sigaction sigio_struct;
Expand Down Expand Up @@ -1556,34 +1557,11 @@ int main(int argc, char **argv) /* {{{ */
} break;

case 'h': {
sapi_startup(phpdbg);
phpdbg->startup(phpdbg);
PHPDBG_G(flags) = 0;
/* It ain't gonna proceed to real execution anyway,
but the correct descriptor is needed already. */
PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout;
PHPDBG_G(io)[PHPDBG_STDOUT].fd = fileno(stdout);
phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);
phpdbg_do_help(NULL);
sapi_deactivate();
sapi_shutdown();
return 0;
show_help = 1;
} break;

case 'V': {
sapi_startup(phpdbg);
phpdbg->startup(phpdbg);
printf(
"phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2016 The PHP Group\n%s",
PHPDBG_VERSION,
__DATE__,
__TIME__,
PHP_VERSION,
get_zend_version()
);
sapi_deactivate();
sapi_shutdown();
return 0;
show_version = 1;
} break;
}

Expand Down Expand Up @@ -1662,6 +1640,51 @@ int main(int argc, char **argv) /* {{{ */
/* set flags from command line */
PHPDBG_G(flags) = flags;

/* set default colors */
phpdbg_set_color_ex(PHPDBG_COLOR_PROMPT, PHPDBG_STRL("white-bold"));
phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold"));
phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green"));

/* set default prompt */
phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);

if (show_version || show_help) {
/* It ain't gonna proceed to real execution anyway,
but the correct descriptor is needed already. */
PHPDBG_G(io)[PHPDBG_STDOUT].ptr = stdout;
PHPDBG_G(io)[PHPDBG_STDOUT].fd = fileno(stdout);
if (show_help) {
phpdbg_do_help(NULL);
} else if (show_version) {
phpdbg_out(
"phpdbg %s (built: %s %s)\nPHP %s, Copyright (c) 1997-2016 The PHP Group\n%s",
PHPDBG_VERSION,
__DATE__,
__TIME__,
PHP_VERSION,
get_zend_version()
);
}
sapi_deactivate();
sapi_shutdown();
if (ini_entries) {
free(ini_entries);
}
if (ini_override) {
free(ini_override);
}
if (exec) {
free(exec);
}
if (oplog_file) {
free(oplog_file);
}
if (init_file) {
free(init_file);
}
goto free_and_return;
}

if (settings > (zend_phpdbg_globals *) 0x2) {
#ifdef ZTS
*((zend_phpdbg_globals *) (*((void ***) TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(phpdbg_globals_id)]) = *settings;
Expand Down Expand Up @@ -1821,14 +1844,6 @@ int main(int argc, char **argv) /* {{{ */
oplog_file = NULL;
}

/* set default colors */
phpdbg_set_color_ex(PHPDBG_COLOR_PROMPT, PHPDBG_STRL("white-bold"));
phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold"));
phpdbg_set_color_ex(PHPDBG_COLOR_NOTICE, PHPDBG_STRL("green"));

/* set default prompt */
phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);

{
php_stream_wrapper *wrapper = zend_hash_str_find_ptr(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php"));
PHPDBG_G(orig_url_wrap_php) = wrapper->wops->stream_opener;
Expand Down Expand Up @@ -2131,6 +2146,7 @@ int main(int argc, char **argv) /* {{{ */
sapi_shutdown();
}

free_and_return:
if (read_from_stdin) {
free(read_from_stdin);
read_from_stdin = NULL;
Expand Down

0 comments on commit d82da7d

Please sign in to comment.