On 28/02/17 20:13, Sara Golemon wrote:
> The average PHP extension is dependent only on the PHP runtime it was
> built for and probably one or more 3rd party libraries.  However, a
> special class of extensions (such as PDO drivers and much of the XML
> family) have dependencies on other PHP extensions which may (or may
> not) be preset at the time they are loaded in via ini settings and/or
> dl().
> 
> This situation was partially addressed by Wez back in PHP 5.2 with the
> addition of zend_module_dep in the module entry header.  Combined with
> RTLD_LAZY during DL_LOAD() (a portability macro for dlopen()), this
> allows modules to be inspected for dependencies and conflicts prior to
> being registered with the runtime.

I, for a long time, thought that the module deps facility was broken,
until I discovered, that it was just not working for me, because I used
a function pointer:
https://github.com/m6w6/ext-http/commit/7493ad081ec06081cb8ca0f804d98a263f93ffbc

> 
> Unfortunately RTLD_LAZY has some limitations.  From `man dlopen`:
> """Lazy binding is performed only for function references; references
> to variables are always immediately bound when the shared object is
> loaded."""  Given PHP's heavy use of XG() macros to access "globals",
> the odds of a missing symbol during module load is therefore fairly
> high resulting in an inability to inspect zend_module_dep structures
> and provide a meaningful error message to end users.

In my book, using XG() should be avoided and must not be used outside of
the owning module. If really needed, there should be an appropriate
public API. IMO.


-- 
Regards,
Mike

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to