php 7.4 "immutable classes" support

Xon

Well-known member
php 7.4 plans to include preloading classes, which are then rendered immutable.

This feature will strongly impact XenForo 2's class extension framework, as preloaded classes can not be re-declared which limits pre-loading add-on classes

Preloading is going to be controlled by just a single new php.ini directive - opcache.preload. Using this directive we will specify a single PHP file - which will perform the preloading task. Once loaded, this file is then fully executed - and may preload other files, either by including them or by using the opcache_compile_file() function

Preloading Limitation
Only classes without unresolved parent, interfaces, traits and constant values may be preloaded. If a class doesn't satisfy to this condition, it's stored in opcache SHM as a part of corresponding PHP script in the same way as without preloading. Also, only top-level entities that are not nested within control structures (e.g. if()…) may be preloaded.

One of the reasons I want to bring this up now, is that the code_cache system could have some relatively small changes to support the contents being "preloaded" and then loading changes with new filenames/classnames.

I'm not sure how easily the class extension system could be adjusted to being automatically pre-loaded
 
Last edited:
Upvote 12
Back
Top Bottom