This is an old revision of the document!
- * Unordered List Item * * Unordered List Item
PHP RFC: Extension load priority
This RFC involves introducing a priority to to the internal loading order of extensions. This is an Engine level feature and cannot be controlled in userland.
Extensions today are loaded in the order they appear in php.ini, this is fine for most of the extensions, however historically there have been some extensions which needed to have a different order in php.ini in order to be loaded, for this RFC I will base it on the exif extension dependency on mbstring.
Exif have until recently been attempted to be loaded before mbstring (because the extension= directive in php.ini are in alphabetic order), this means the dependency checking mechanism fails as mbstring simply is not loaded, despite its next in the list of extensions to be loaded. To overcome this in an easily (and elegant manner, which ofcourse is not only specific to this issue), a priority loading mechanism can be implemented directly into the zend_module_entry struct.
The patch (see below), will add/change the following items:
- Change zend_module_entry, and add a new member: 'int load_priority', whether this is gonna be hidden in STANDARD_MODULE_PROPERTIES or the _EX is debatable, but forcing it to always be present will not make any sense as most extensions do not need to define this, only modules with dependencies
- Both zend_extension=s and extension=s will have this feature, meaning the above applies to both extension structs.
- There will be a varity of verbose constants (that masks to an integer) available:
- * ZEND_EXTPRIO_FIRST(1) - First priority, attempt to load first
- ZEND_EXTPRIO_SECOND(3) - Secondary priority, early load extension too, may depend on an extension with 'first' priority
- ZEND_EXTPRIO_DEFAULT(5) - Default value, will be used in the STANDARD_MODULE_PROPERTIES[_EX] macro (like mbstring)
- ZEND_EXTPRIO_DEP(7) - Dependency on a default extension (like exif)
- ZEND_EXTPRIO_LAST(9) - Load last
- Extensions in core will have a separate patch, same goes for PECL (if requested)
- A macro for cross extension developers will be included in this RFC once the implementation is complete
Note, the value of ZEND_EXTPRIO_SECOND that defaults to 3 is intended. Note, values below 1 is not allowed and values above 9 can be used but since we don't really need a bigger namespace range, 9 will do for last loading for now. Other values between 1 and 9 thats not masked to a constant can be used manually for tweaks, should that be needed.
An implementation patch is currently being worked upon.