@@ -1200,6 +1200,8 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
1200
1200
/* store script structure in the hash table */
1201
1201
bucket = zend_accel_hash_update (& ZCSG (hash ), new_persistent_script -> full_path , new_persistent_script -> full_path_len + 1 , 0 , new_persistent_script );
1202
1202
if (bucket &&
1203
+ /* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
1204
+ memcmp (key , "phar://" , sizeof ("phar://" ) - 1 ) != 0 &&
1203
1205
(new_persistent_script -> full_path_len != key_length ||
1204
1206
memcmp (new_persistent_script -> full_path , key , key_length ) != 0 )) {
1205
1207
/* link key to the same persistent script in hash table */
@@ -1655,7 +1657,18 @@ zend_op_array *persistent_compile_file(zend_file_handle *file_handle, int type T
1655
1657
#endif
1656
1658
void * dummy = (void * ) 1 ;
1657
1659
1658
- 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 );
1660
+ 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 ) {
1661
+ /* ext/phar has to load phar's metadata into memory */
1662
+ if (strstr (persistent_script -> full_path , ".phar" ) && !strstr (persistent_script -> full_path , "://" )) {
1663
+ php_stream_statbuf ssb ;
1664
+ char * fname = emalloc (sizeof ("phar://" ) + persistent_script -> full_path_len );
1665
+
1666
+ memcpy (fname , "phar://" , sizeof ("phar://" ) - 1 );
1667
+ memcpy (fname + sizeof ("phar://" ) - 1 , persistent_script -> full_path , persistent_script -> full_path_len + 1 );
1668
+ php_stream_stat_path (fname , & ssb );
1669
+ efree (fname );
1670
+ }
1671
+ }
1659
1672
}
1660
1673
}
1661
1674
#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
0 commit comments