Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZEND_MOD_CONFLICTS doesn't work #14067

Open
petk opened this issue Apr 28, 2024 · 0 comments
Open

ZEND_MOD_CONFLICTS doesn't work #14067

petk opened this issue Apr 28, 2024 · 0 comments

Comments

@petk
Copy link
Member

petk commented Apr 28, 2024

Description

When building PHP extension that has ZEND_MOD_CONFLICTS listed in its dependencies, the macro is ineffective when building shared extensions or when conflicting module is registered after such extension.

For example. Suppose we add the following hypothetical change to ext/ctype/ctyp.c (to mark the ext/curl extension as conflicting for the ext/ctype):

diff --git a/ext/ctype/ctype.c b/ext/ctype/ctype.c
--- a/ext/ctype/ctype.c
+++ b/ext/ctype/ctype.c
@@ -33,9 +33,15 @@ static PHP_MINFO_FUNCTION(ctype);
 
 /* }}} */
 
+static const zend_module_dep ctype_deps[] = {
+       ZEND_MOD_CONFLICTS("curl")
+       ZEND_MOD_END
+};
+
 /* {{{ ctype_module_entry */
 zend_module_entry ctype_module_entry = {
-       STANDARD_MODULE_HEADER,
+       STANDARD_MODULE_HEADER_EX, NULL,
+       ctype_deps,
        "ctype",
        ext_functions,
        NULL,
(END)

Then building it with:

./buildconf
./configure --enable-ctype=shared --with-curl=shared
make
./sapi/cli/php -d extension_dir=modules -d extension=ctype -d extension=curl -m

Resulted in this output (here no warning is given):

[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
...
[Zend Modules]

But I expected this output instead:

Warning: Cannot load module "ctype" because conflicting module "curl" is already loaded in Unknown on line 0
[PHP Modules]
Core
curl
date
dom
fileinfo
filter
...
[Zend Modules]

Unlike, when doing:

./sapi/cli/php -d extension_dir=modules -d extension=curl -d extension=ctype -m

the warning is displayed and extension is not loaded as it should be done.

PHP Version

All

Operating System

No response

petk added a commit to petk/php-src that referenced this issue Apr 28, 2024
When extension has conflicting extension(s) listed in ZEND_MOD_CONFLICTS
this now properly emits a warning and doesn't load the extension.

Previously it relied on the sort order of the registered extensions:
- first the statically built extensions based on the
  PHP_ADD_EXTENSION_DEP (*nix) or ADD_EXTENSION_DEP (Windows)
  listed in the main/internal_functions.c or
  main/internal_functions_cli.c.
- then dynamically loaded extensions using the extension=<ext> and
  zend_extension=<ext> INI directives.

And it didn't detect conflicting extensions when they were loaded later
in the list or when loaded as shared modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant