@@ -1200,6 +1200,8 @@ static zend_persistent_script *cache_script_in_shared_memory(zend_persistent_scr
12001200 /* store script structure in the hash table */
12011201 bucket = zend_accel_hash_update (& ZCSG (hash ), new_persistent_script -> full_path , new_persistent_script -> full_path_len + 1 , 0 , new_persistent_script );
12021202 if (bucket &&
1203+ /* key may contain non-persistent PHAR aliases (see issues #115 and #149) */
1204+ memcmp (key , "phar://" , sizeof ("phar://" ) - 1 ) != 0 &&
12031205 (new_persistent_script -> full_path_len != key_length ||
12041206 memcmp (new_persistent_script -> full_path , key , key_length ) != 0 )) {
12051207 /* 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
16551657#endif
16561658 void * dummy = (void * ) 1 ;
16571659
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+ }
16591672 }
16601673 }
16611674#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO
0 commit comments