]> granicus.if.org Git - php/commitdiff
Fixed bug #39542 (Behaviour of require/include different to < 5.2.0)
authorDmitry Stogov <dmitry@php.net>
Fri, 11 May 2007 08:03:00 +0000 (08:03 +0000)
committerDmitry Stogov <dmitry@php.net>
Fri, 11 May 2007 08:03:00 +0000 (08:03 +0000)
Zend/tests/bug39542.phpt [new file with mode: 0755]
Zend/tests/bug39542/bug39542.php [new file with mode: 0755]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/Zend/tests/bug39542.phpt b/Zend/tests/bug39542.phpt
new file mode 100755 (executable)
index 0000000..13ddc0a
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #39542 (Behaviour of require_once/include_once different to < 5.2.0)
+--FILE--
+<?php
+$oldcwd = getcwd();
+chdir(dirname(__FILE__));
+if (substr(PHP_OS, 0, 3) == 'WIN') {
+       set_include_path(dirname(__FILE__).'/bug39542;.');
+} else {
+       set_include_path(dirname(__FILE__).'/bug39542:.');
+}
+
+function __autoload($class) {
+    if (!require_once($class.'.php')) {
+        error_log('Error: Autoload class: '.$class.' not found!');
+    }
+}
+
+new bug39542();
+
+chdir($oldcwd);
+?>
+--EXPECT--
+ok
diff --git a/Zend/tests/bug39542/bug39542.php b/Zend/tests/bug39542/bug39542.php
new file mode 100755 (executable)
index 0000000..90cb36c
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+class bug39542 {
+       function bug39542() {
+               echo "ok\n";
+       }
+}
+?>
index 409f589f05566d316c52d95228b478b419023176..e1c9e9e122f03eca427ce441f92feb110d3e4f43 100644 (file)
@@ -2870,22 +2870,19 @@ ZEND_VM_HANDLER(73, ZEND_INCLUDE_OR_EVAL, CONST|TMP|VAR|CV, ANY)
                case ZEND_INCLUDE_ONCE:
                case ZEND_REQUIRE_ONCE: {
                                zend_file_handle file_handle;
-                               char cwd[MAXPATHLEN];
-                               cwd_state state;
 
                                if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) {
-                                       cwd[0] = '\0';
-                               } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
-                                       cwd[0] = '\0';
-                               }
-
-                               state.cwd_length = strlen(cwd);
-                               state.cwd = zend_strndup(cwd, state.cwd_length);
+                                       cwd_state state;
+       
+                                       state.cwd_length = 0;
+                                       state.cwd = malloc(1);
+                                       state.cwd[0] = 0;
 
-                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+                                       failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                               zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
 
-                               free(state.cwd);
+                                       free(state.cwd);
+                               }
 
                                if (failure_retval) {
                                        /* do nothing */
index 7effc06f90d7c5b8b5cd41f021f8d00b1476fb18..3c06458da3df21dc0d9403e1308d739b161d984e 100644 (file)
@@ -1955,22 +1955,19 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                case ZEND_INCLUDE_ONCE:
                case ZEND_REQUIRE_ONCE: {
                                zend_file_handle file_handle;
-                               char cwd[MAXPATHLEN];
-                               cwd_state state;
 
                                if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) {
-                                       cwd[0] = '\0';
-                               } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
-                                       cwd[0] = '\0';
-                               }
+                                       cwd_state state;
 
-                               state.cwd_length = strlen(cwd);
-                               state.cwd = zend_strndup(cwd, state.cwd_length);
+                                       state.cwd_length = 0;
+                                       state.cwd = malloc(1);
+                                       state.cwd[0] = 0;
 
-                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+                                       failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                               zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
 
-                               free(state.cwd);
+                                       free(state.cwd);
+                               }
 
                                if (failure_retval) {
                                        /* do nothing */
@@ -4633,22 +4630,19 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                case ZEND_INCLUDE_ONCE:
                case ZEND_REQUIRE_ONCE: {
                                zend_file_handle file_handle;
-                               char cwd[MAXPATHLEN];
-                               cwd_state state;
 
                                if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) {
-                                       cwd[0] = '\0';
-                               } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
-                                       cwd[0] = '\0';
-                               }
+                                       cwd_state state;
 
-                               state.cwd_length = strlen(cwd);
-                               state.cwd = zend_strndup(cwd, state.cwd_length);
+                                       state.cwd_length = 0;
+                                       state.cwd = malloc(1);
+                                       state.cwd[0] = 0;
 
-                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+                                       failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                               zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
 
-                               free(state.cwd);
+                                       free(state.cwd);
+                               }
 
                                if (failure_retval) {
                                        /* do nothing */
@@ -7894,22 +7888,19 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                case ZEND_INCLUDE_ONCE:
                case ZEND_REQUIRE_ONCE: {
                                zend_file_handle file_handle;
-                               char cwd[MAXPATHLEN];
-                               cwd_state state;
 
                                if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) {
-                                       cwd[0] = '\0';
-                               } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
-                                       cwd[0] = '\0';
-                               }
+                                       cwd_state state;
 
-                               state.cwd_length = strlen(cwd);
-                               state.cwd = zend_strndup(cwd, state.cwd_length);
+                                       state.cwd_length = 0;
+                                       state.cwd = malloc(1);
+                                       state.cwd[0] = 0;
 
-                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+                                       failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                               zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
 
-                               free(state.cwd);
+                                       free(state.cwd);
+                               }
 
                                if (failure_retval) {
                                        /* do nothing */
@@ -20539,22 +20530,19 @@ static int ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                case ZEND_INCLUDE_ONCE:
                case ZEND_REQUIRE_ONCE: {
                                zend_file_handle file_handle;
-                               char cwd[MAXPATHLEN];
-                               cwd_state state;
 
                                if (IS_ABSOLUTE_PATH(Z_STRVAL_P(inc_filename), Z_STRLEN_P(inc_filename))) {
-                                       cwd[0] = '\0';
-                               } else if (!VCWD_GETCWD(cwd, MAXPATHLEN)) {
-                                       cwd[0] = '\0';
-                               }
+                                       cwd_state state;
 
-                               state.cwd_length = strlen(cwd);
-                               state.cwd = zend_strndup(cwd, state.cwd_length);
+                                       state.cwd_length = 0;
+                                       state.cwd = malloc(1);
+                                       state.cwd[0] = 0;
 
-                               failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
-                                       zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
+                                       failure_retval = (!virtual_file_ex(&state, Z_STRVAL_P(inc_filename), NULL, 1) &&
+                                               zend_hash_exists(&EG(included_files), state.cwd, state.cwd_length+1));
 
-                               free(state.cwd);
+                                       free(state.cwd);
+                               }
 
                                if (failure_retval) {
                                        /* do nothing */