@@ -225,7 +225,7 @@ static zend_persistent_script *zum_compile_file(zend_user_module *module, zend_f
225225 if (!persistent_script ) {
226226 /* For PoC purpose, we only support files that can be cached in SHM for
227227 * now. */
228- zend_error_noreturn (E_ERROR , "File %s could not be cached in SHM. This is unsupported in modules (yet)." ,
228+ zend_error_noreturn (E_ERROR , "File %s could not be cached in opcache ( SHM or file cache) . This is unsupported in modules (yet)." ,
229229 ZSTR_VAL (file_handle -> filename ));
230230 return NULL ;
231231 }
@@ -584,7 +584,7 @@ static zend_result zum_check_deps_class(zend_user_module *module, zend_class_ent
584584 if (!zend_string_equals (ce -> info .user .module , module -> desc .lcname )) {
585585 ZUM_DEBUG ("Module %s depends on %s\n" , ZSTR_VAL (module -> desc .lcname ), ZSTR_VAL (ce -> info .user .module ));
586586
587- if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE )) {
587+ if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE ) && ! ZCG ( accel_directives ). file_cache_only ) {
588588 zend_throw_error (NULL ,
589589 "Module %s can not depend on uncacheable class %s" ,
590590 ZSTR_VAL (module -> desc .name ), ZSTR_VAL (ce -> name ));
@@ -616,7 +616,7 @@ static zend_result zum_check_deps_class_decl(zend_user_module *module, zend_clas
616616 ZEND_ASSERT (!EG (exception ));
617617 ZEND_ASSERT (ce -> ce_flags & ZEND_ACC_LINKED );
618618
619- if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE )) {
619+ if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE ) && ! ZCG ( accel_directives ). file_cache_only ) {
620620 zend_throw_error (NULL ,
621621 "Class %s is uncacheable" ,
622622 ZSTR_VAL (ce -> name ));
@@ -1313,7 +1313,7 @@ ZEND_API void zend_require_user_module(zend_string *module_path)
13131313
13141314 ZUM_DEBUG ("require module: %s\n" , ZSTR_VAL (module_path ));
13151315
1316- if (!ZCG (accelerator_enabled )) {
1316+ if (!ZCG (accelerator_enabled ) && ! ZCG ( accel_directives ). file_cache ) {
13171317 zend_throw_error (NULL , "require_modules() not supported when opcache is not enabled, yet" );
13181318 return ;
13191319 }
@@ -1330,21 +1330,23 @@ ZEND_API void zend_require_user_module(zend_string *module_path)
13301330 zend_stream_init_filename_ex (& file_handle , full_path );
13311331 zend_string_release (full_path );
13321332
1333- zend_string * module_key = zend_string_concat2 (
1334- "module://" , strlen ("module://" ),
1335- ZSTR_VAL (file_handle .filename ), ZSTR_LEN (file_handle .filename ));
1336- zend_persistent_user_module * cached_module = zend_accel_hash_find (& ZCSG (hash ), module_key );
1337- zend_string_release (module_key );
1338- if (cached_module ) {
1339- zend_user_module * loaded_module = zend_hash_find_ptr (EG (module_table ), cached_module -> module .desc .lcname );
1340- if (loaded_module ) {
1341- zum_handle_loaded_module (loaded_module , file_handle .filename );
1342- zend_destroy_file_handle (& file_handle );
1343- return ;
1344- }
1345- if (zum_load (& file_handle , cached_module ) == SUCCESS ) {
1346- zend_destroy_file_handle (& file_handle );
1347- return ;
1333+ if (ZCG (accelerator_enabled )) {
1334+ zend_string * module_key = zend_string_concat2 (
1335+ "module://" , strlen ("module://" ),
1336+ ZSTR_VAL (file_handle .filename ), ZSTR_LEN (file_handle .filename ));
1337+ zend_persistent_user_module * cached_module = zend_accel_hash_find (& ZCSG (hash ), module_key );
1338+ zend_string_release (module_key );
1339+ if (cached_module ) {
1340+ zend_user_module * loaded_module = zend_hash_find_ptr (EG (module_table ), cached_module -> module .desc .lcname );
1341+ if (loaded_module ) {
1342+ zum_handle_loaded_module (loaded_module , file_handle .filename );
1343+ zend_destroy_file_handle (& file_handle );
1344+ return ;
1345+ }
1346+ if (zum_load (& file_handle , cached_module ) == SUCCESS ) {
1347+ zend_destroy_file_handle (& file_handle );
1348+ return ;
1349+ }
13481350 }
13491351 }
13501352
@@ -1600,6 +1602,11 @@ static void zum_persist_modules(uint32_t module_table_offset)
16001602{
16011603 ZEND_ASSERT (!CG (active_module ));
16021604
1605+ if (ZCG (accel_directives ).file_cache_only ) {
1606+ // TODO: leaks
1607+ return ;
1608+ }
1609+
16031610 zend_shared_alloc_init_xlat_table ();
16041611
16051612 /* Replace zend_user_modules by zend_persistent_user_modules
0 commit comments