summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2013-11-08 16:35:05 +0400
committerDmitry Stogov <dmitry@zend.com>2013-11-08 16:35:05 +0400
commit915c428ba1006a144c4fca45e44631ec058a5074 (patch)
treea71ab6b2d1b687634f038bb04379545b0d9e7303
parent49fbe2579e9cbb4314346c8eaf959c670de0abdb (diff)
downloadphp-git-915c428ba1006a144c4fca45e44631ec058a5074.tar.gz
Fixed issue #115 (path issue when using phar).
Fixed issue #149 (Phar mount points not working with OPcache enabled).
-rw-r--r--NEWS3
-rw-r--r--ext/opcache/ZendAccelerator.c15
2 files changed, 17 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 0fd30ced06..d0359fe185 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,9 @@ PHP NEWS
- OPcache
. Increased limit for opcache.max_accelerated_files to 1,000,000. (Chris)
+ . Fixed issue #115 (path issue when using phar). (Dmitry)
+ . Fixed issue #149 (Phar mount points not working with OPcache enabled).
+ (Dmitry)
- ODBC
. Fixed bug #65950 (Field name truncation if the field name is bigger than
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 72b5a1b9fe..8eaa0a3778 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -1196,6 +1196,8 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
/* store script structure in the hash table */
bucket = zend_accel_hash_update(&ZCSG(hash), new_persistent_script->full_path, new_persistent_script->full_path_len + 1, 0, new_persistent_script);
if (bucket &&
+ /* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
+ memcmp(key, "phar://", sizeof("phar://") - 1) != 0 &&
(new_persistent_script->full_path_len != key_length ||
memcmp(new_persistent_script->full_path, key, key_length) != 0)) {
/* 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
#endif
void *dummy = (void *) 1;
- 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);
+ 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) {
+ /* ext/phar has to load phar's metadata into memory */
+ if (strstr(persistent_script->full_path, ".phar") && !strstr(persistent_script->full_path, "://")) {
+ php_stream_statbuf ssb;
+ char *fname = emalloc(sizeof("phar://") + persistent_script->full_path_len);
+
+ memcpy(fname, "phar://", sizeof("phar://") - 1);
+ memcpy(fname + sizeof("phar://") - 1, persistent_script->full_path, persistent_script->full_path_len + 1);
+ php_stream_stat_path(fname, &ssb);
+ efree(fname);
+ }
+ }
}
}
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO