Skip to content

Commit 915c428

Browse files
committed
Fixed issue #115 (path issue when using phar).
Fixed issue #149 (Phar mount points not working with OPcache enabled).
1 parent 49fbe25 commit 915c428

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ PHP NEWS
2121

2222
- OPcache
2323
. Increased limit for opcache.max_accelerated_files to 1,000,000. (Chris)
24+
. Fixed issue #115 (path issue when using phar). (Dmitry)
25+
. Fixed issue #149 (Phar mount points not working with OPcache enabled).
26+
(Dmitry)
2427

2528
- ODBC
2629
. Fixed bug #65950 (Field name truncation if the field name is bigger than

ext/opcache/ZendAccelerator.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
11961196
/* store script structure in the hash table */
11971197
bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path, new_persistent_script->full_path_len + 1, 0, new_persistent_script);
11981198
if (bucket &&
1199+
/* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
1200+
memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
11991201
(new_persistent_script->full_path_len != key_length ||
12001202
memcmp(new_persistent_script->full_path, key, key_length) != 0)) {
12011203
/* link key to the same persistent script in hash table */
@@ -1651,7 +1653,18 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
16511653
#endif
16521654
void *dummy = (void *) 1;
16531655

1654-
zend_hash_quick_add(&EG(included_files), persistent_script->full_path, persistent_script->full_path_len + 1, persistent_script->hash_value, &dummy, sizeof(void *), NULL);
1656+
if (zend_hash_quick_add(&EG(included_files), persistent_script->full_path, persistent_script->full_path_len + 1, persistent_script->hash_value, &dummy, sizeof(void *), NULL) == SUCCESS) {
1657+
/* ext/phar has to load phar's metadata into memory */
1658+
if (strstr(persistent_script->full_path, ".phar") && !strstr(persistent_script->full_path, "://")) {
1659+
php_stream_statbuf ssb;
1660+
char *fname = emalloc(sizeof("phar://") + persistent_script->full_path_len);
1661+
1662+
memcpy(fname, "phar://", sizeof("phar://") - 1);
1663+
memcpy(fname + sizeof("phar://") - 1, persistent_script->full_path, persistent_script->full_path_len + 1);
1664+
php_stream_stat_path(fname, &ssb);
1665+
efree(fname);
1666+
}
1667+
}
16551668
}
16561669
}
16571670
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO

0 commit comments

Comments
 (0)