@@ -225,7 +225,7 @@ static zend_persistent_script *zum_compile_file(zend_user_module *module, zend_f
225
225
if (!persistent_script ) {
226
226
/* For PoC purpose, we only support files that can be cached in SHM for
227
227
* 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)." ,
229
229
ZSTR_VAL (file_handle -> filename ));
230
230
return NULL ;
231
231
}
@@ -584,7 +584,7 @@ static zend_result zum_check_deps_class(zend_user_module *module, zend_class_ent
584
584
if (!zend_string_equals (ce -> info .user .module , module -> desc .lcname )) {
585
585
ZUM_DEBUG ("Module %s depends on %s\n" , ZSTR_VAL (module -> desc .lcname ), ZSTR_VAL (ce -> info .user .module ));
586
586
587
- if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE )) {
587
+ if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE ) && ! ZCG ( accel_directives ). file_cache_only ) {
588
588
zend_throw_error (NULL ,
589
589
"Module %s can not depend on uncacheable class %s" ,
590
590
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
616
616
ZEND_ASSERT (!EG (exception ));
617
617
ZEND_ASSERT (ce -> ce_flags & ZEND_ACC_LINKED );
618
618
619
- if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE )) {
619
+ if (!(ce -> ce_flags & ZEND_ACC_IMMUTABLE ) && ! ZCG ( accel_directives ). file_cache_only ) {
620
620
zend_throw_error (NULL ,
621
621
"Class %s is uncacheable" ,
622
622
ZSTR_VAL (ce -> name ));
@@ -1313,7 +1313,7 @@ ZEND_API void zend_require_user_module(zend_string *module_path)
1313
1313
1314
1314
ZUM_DEBUG ("require module: %s\n" , ZSTR_VAL (module_path ));
1315
1315
1316
- if (!ZCG (accelerator_enabled )) {
1316
+ if (!ZCG (accelerator_enabled ) && ! ZCG ( accel_directives ). file_cache ) {
1317
1317
zend_throw_error (NULL , "require_modules() not supported when opcache is not enabled, yet" );
1318
1318
return ;
1319
1319
}
@@ -1330,21 +1330,23 @@ ZEND_API void zend_require_user_module(zend_string *module_path)
1330
1330
zend_stream_init_filename_ex (& file_handle , full_path );
1331
1331
zend_string_release (full_path );
1332
1332
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
+ }
1348
1350
}
1349
1351
}
1350
1352
@@ -1600,6 +1602,11 @@ static void zum_persist_modules(uint32_t module_table_offset)
1600
1602
{
1601
1603
ZEND_ASSERT (!CG (active_module ));
1602
1604
1605
+ if (ZCG (accel_directives ).file_cache_only ) {
1606
+ // TODO: leaks
1607
+ return ;
1608
+ }
1609
+
1603
1610
zend_shared_alloc_init_xlat_table ();
1604
1611
1605
1612
/* Replace zend_user_modules by zend_persistent_user_modules
0 commit comments