Fixed bug #73615 (phpdbg without option never load .phpdbginit at startup)
authorBob Weinand <bobwei9@hotmail.com>
Wed, 30 Nov 2016 01:56:47 +0000 (02:56 +0100)
committerBob Weinand <bobwei9@hotmail.com>
Wed, 30 Nov 2016 01:56:47 +0000 (02:56 +0100)
NEWS
sapi/phpdbg/phpdbg.c
sapi/phpdbg/phpdbg_prompt.c
sapi/phpdbg/tests/bug73615.phpt [new file with mode: 0644]
sapi/phpdbg/tests/bug73615/.phpdbginit [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 79ced5e62bfb33421985397a1588775f38e6d399..1bd6df98cdd4b8c5720243a5755cd9c144d71739 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,10 @@ PHP                                                                        NEWS
   . Fixed bug #73586 (php_user_filter::$stream is not set to the stream the
     filter is working on). (Dmitry)
 
+- Phpdbg:
+  . Fixed bug #73615 (phpdbg without option never load .phpdbginit at startup).
+    (Bob)
+
 08 Dec 2016 PHP 7.0.14
 
 - Core:
index 148e18a454b7d745a53457fc72a51ee7db60a0ac..7eeaf48d79edcff8efb24b21d97040def9c29ca4 100644 (file)
@@ -1874,9 +1874,7 @@ phpdbg_main:
                /* initialize from file */
                PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING;
                zend_try {
-                       if (init_file) {
-                               phpdbg_init(init_file, init_file_len, init_file_default);
-                       }
+                       phpdbg_init(init_file, init_file_len, init_file_default);
                } zend_end_try();
                PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING;
 
index c126ce2029f14f4d58fdf323ed512e5d5e997fc5..4ee27d1beb250054915b3318307d6952712f5962 100644 (file)
@@ -349,7 +349,9 @@ void phpdbg_try_file_init(char *init_file, size_t init_file_len, zend_bool free_
 
 void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default) /* {{{ */
 {
-       if (!init_file && use_default) {
+       if (init_file) {
+               phpdbg_try_file_init(init_file, init_file_len, 1);
+       } else if (use_default) {
                char *scan_dir = getenv("PHP_INI_SCAN_DIR");
                char *sys_ini;
                int i;
@@ -382,8 +384,6 @@ void phpdbg_init(char *init_file, size_t init_file_len, zend_bool use_default) /
                }
 
                phpdbg_try_file_init(PHPDBG_STRL(PHPDBG_INIT_FILENAME), 0);
-       } else {
-               phpdbg_try_file_init(init_file, init_file_len, 1);
        }
 }
 /* }}} */
diff --git a/sapi/phpdbg/tests/bug73615.phpt b/sapi/phpdbg/tests/bug73615.phpt
new file mode 100644 (file)
index 0000000..ade957e
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+Bug #73615 (phpdbg without option never load .phpdbginit at startup)
+--SKIPIF--
+<?php
+if (!getenv('TEST_PHPDBG_EXECUTABLE')) die("No TEST_PHPDBG_EXECUTABLE specified");
+?>
+--FILE--
+<?php
+
+$phpdbg = getenv('TEST_PHPDBG_EXECUTABLE');
+
+chdir(__DIR__."/bug73615");
+
+print `$phpdbg -qn`;
+
+?>
+--EXPECT--
+Executed .phpdbginit
diff --git a/sapi/phpdbg/tests/bug73615/.phpdbginit b/sapi/phpdbg/tests/bug73615/.phpdbginit
new file mode 100644 (file)
index 0000000..29184dd
--- /dev/null
@@ -0,0 +1,2 @@
+ev "Executed .phpdbginit"
+q