Skip to content

Commit c23806d

Browse files
committed
Fixed realpath() cache for main script with FastCGI SAPI
1 parent 29bc693 commit c23806d

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

main/main.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,6 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
17521752
#else
17531753
char *old_cwd;
17541754
#endif
1755-
char *old_primary_file_path = NULL;
17561755
int retval = 0;
17571756

17581757
EG(exit_status) = 0;
@@ -1789,16 +1788,14 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
17891788
/* Only lookup the real file path and add it to the included_files list if already opened
17901789
* otherwise it will get opened and added to the included_files list in zend_execute_scripts
17911790
*/
1792-
if (primary_file->filename && primary_file->type != ZEND_HANDLE_FILENAME) {
1791+
if (primary_file->filename &&
1792+
primary_file->opened_path == NULL &&
1793+
primary_file->type != ZEND_HANDLE_FILENAME) {
17931794
int realfile_len;
17941795
int dummy = 1;
17951796
if (VCWD_REALPATH(primary_file->filename, realfile)) {
17961797
realfile_len = strlen(realfile);
17971798
zend_hash_add(&EG(included_files), realfile, realfile_len+1, (void *)&dummy, sizeof(int), NULL);
1798-
if (strncmp(realfile, primary_file->filename, realfile_len)) {
1799-
old_primary_file_path = primary_file->filename;
1800-
primary_file->filename = realfile;
1801-
}
18021799
}
18031800
}
18041801

@@ -1827,10 +1824,6 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file TSRMLS_DC)
18271824
zend_set_timeout(INI_INT("max_execution_time"));
18281825
retval = (zend_execute_scripts(ZEND_REQUIRE TSRMLS_CC, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
18291826

1830-
if (old_primary_file_path) {
1831-
primary_file->filename = old_primary_file_path;
1832-
}
1833-
18341827
} zend_end_try();
18351828

18361829
#if HAVE_BROKEN_GETCWD

0 commit comments

Comments
 (0)