-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix unregistering ini entries of dynamically loaded extension #8435
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
PHP_ARG_ENABLE([dl-test], | ||
[whether to enable dl-test extension], | ||
[AS_HELP_STRING([--enable-dl-test], | ||
[Enable dl_test extension])]) | ||
|
||
if test "$PHP_DL_TEST" != "no"; then | ||
PHP_NEW_EXTENSION(dl_test, dl_test.c, [shared],, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// vim:ft=javascript | ||
|
||
ARG_ENABLE("dl-test", "enable dl_test extension", "no"); | ||
|
||
if (PHP_DL_TEST != "no") { | ||
EXTENSION("dl_test", "dl_test.c", true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); | ||
ADD_FLAG("CFLAGS_DL_TEST", "/D PHP_DL_TEST_EXPORTS "); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) The PHP Group | | ||
+----------------------------------------------------------------------+ | ||
| This source file is subject to version 3.01 of the PHP license, | | ||
| that is bundled with this package in the file LICENSE, and is | | ||
| available through the world-wide-web at the following url: | | ||
| https://www.php.net/license/3_01.txt | | ||
| If you did not receive a copy of the PHP license and are unable to | | ||
| obtain it through the world-wide-web, please send a note to | | ||
| [email protected] so we can mail you a copy immediately. | | ||
+----------------------------------------------------------------------+ | ||
| Author: Arnaud Le Blanc <[email protected]> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
# include "config.h" | ||
#endif | ||
|
||
#include "php.h" | ||
#include "ext/standard/info.h" | ||
#include "php_dl_test.h" | ||
#include "dl_test_arginfo.h" | ||
|
||
ZEND_DECLARE_MODULE_GLOBALS(dl_test) | ||
|
||
/* {{{ void dl_test_test1() */ | ||
PHP_FUNCTION(dl_test_test1) | ||
{ | ||
ZEND_PARSE_PARAMETERS_NONE(); | ||
|
||
php_printf("The extension %s is loaded and working!\r\n", "dl_test"); | ||
} | ||
/* }}} */ | ||
|
||
/* {{{ string dl_test_test2( [ string $var ] ) */ | ||
PHP_FUNCTION(dl_test_test2) | ||
{ | ||
char *var = "World"; | ||
size_t var_len = sizeof("World") - 1; | ||
zend_string *retval; | ||
|
||
ZEND_PARSE_PARAMETERS_START(0, 1) | ||
Z_PARAM_OPTIONAL | ||
Z_PARAM_STRING(var, var_len) | ||
ZEND_PARSE_PARAMETERS_END(); | ||
|
||
retval = strpprintf(0, "Hello %s", var); | ||
|
||
RETURN_STR(retval); | ||
} | ||
/* }}}*/ | ||
|
||
/* {{{ INI */ | ||
PHP_INI_BEGIN() | ||
STD_PHP_INI_BOOLEAN("dl_test.long", "0", PHP_INI_ALL, OnUpdateLong, long_value, zend_dl_test_globals, dl_test_globals) | ||
STD_PHP_INI_ENTRY("dl_test.string", "hello", PHP_INI_ALL, OnUpdateString, string_value, zend_dl_test_globals, dl_test_globals) | ||
PHP_INI_END() | ||
/* }}} */ | ||
|
||
/* {{{ PHP_MINIT_FUNCTION */ | ||
PHP_MINIT_FUNCTION(dl_test) | ||
{ | ||
/* Test backwards compatibility */ | ||
if (getenv("PHP_DL_TEST_USE_OLD_REGISTER_INI_ENTRIES")) { | ||
zend_register_ini_entries(ini_entries, module_number); | ||
} else { | ||
REGISTER_INI_ENTRIES(); | ||
} | ||
|
||
return SUCCESS; | ||
} | ||
/* }}} */ | ||
|
||
/* {{{ PHP_MSHUTDOWN_FUNCTION */ | ||
static PHP_MSHUTDOWN_FUNCTION(dl_test) | ||
{ | ||
/* Test backwards compatibility */ | ||
if (getenv("PHP_DL_TEST_USE_OLD_REGISTER_INI_ENTRIES")) { | ||
zend_unregister_ini_entries(module_number); | ||
} else { | ||
UNREGISTER_INI_ENTRIES(); | ||
} | ||
|
||
return SUCCESS; | ||
} | ||
/* }}} */ | ||
|
||
/* {{{ PHP_RINIT_FUNCTION */ | ||
PHP_RINIT_FUNCTION(dl_test) | ||
{ | ||
#if defined(ZTS) && defined(COMPILE_DL_DL_TEST) | ||
ZEND_TSRMLS_CACHE_UPDATE(); | ||
#endif | ||
|
||
return SUCCESS; | ||
} | ||
/* }}} */ | ||
|
||
/* {{{ PHP_MINFO_FUNCTION */ | ||
PHP_MINFO_FUNCTION(dl_test) | ||
{ | ||
php_info_print_table_start(); | ||
php_info_print_table_header(2, "dl_test support", "enabled"); | ||
php_info_print_table_end(); | ||
|
||
DISPLAY_INI_ENTRIES(); | ||
} | ||
/* }}} */ | ||
|
||
/* {{{ PHP_GINIT_FUNCTION */ | ||
static PHP_GINIT_FUNCTION(dl_test) | ||
{ | ||
#if defined(COMPILE_DL_DL_TEST) && defined(ZTS) | ||
ZEND_TSRMLS_CACHE_UPDATE(); | ||
#endif | ||
memset(dl_test_globals, 0, sizeof(*dl_test_globals)); | ||
} | ||
/* }}} */ | ||
|
||
/* {{{ dl_test_module_entry */ | ||
zend_module_entry dl_test_module_entry = { | ||
STANDARD_MODULE_HEADER, | ||
"dl_test", | ||
ext_functions, | ||
PHP_MINIT(dl_test), | ||
PHP_MSHUTDOWN(dl_test), | ||
PHP_RINIT(dl_test), | ||
NULL, | ||
PHP_MINFO(dl_test), | ||
PHP_DL_TEST_VERSION, | ||
PHP_MODULE_GLOBALS(dl_test), | ||
PHP_GINIT(dl_test), | ||
NULL, | ||
NULL, | ||
STANDARD_MODULE_PROPERTIES_EX | ||
}; | ||
/* }}} */ | ||
|
||
#ifdef COMPILE_DL_DL_TEST | ||
# ifdef ZTS | ||
ZEND_TSRMLS_CACHE_DEFINE() | ||
# endif | ||
ZEND_GET_MODULE(dl_test) | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
/** @generate-class-entries */ | ||
|
||
function dl_test_test1(): void {} | ||
|
||
function dl_test_test2(string $str = ""): string {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* This is a generated file, edit the .stub.php file instead. | ||
* Stub hash: 39ccf8141b0eb785cafd490b420f2e99d6a7a66d */ | ||
|
||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl_test_test1, 0, 0, IS_VOID, 0) | ||
ZEND_END_ARG_INFO() | ||
|
||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl_test_test2, 0, 0, IS_STRING, 0) | ||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, str, IS_STRING, 0, "\"\"") | ||
ZEND_END_ARG_INFO() | ||
|
||
|
||
ZEND_FUNCTION(dl_test_test1); | ||
ZEND_FUNCTION(dl_test_test2); | ||
|
||
|
||
static const zend_function_entry ext_functions[] = { | ||
ZEND_FE(dl_test_test1, arginfo_dl_test_test1) | ||
ZEND_FE(dl_test_test2, arginfo_dl_test_test2) | ||
ZEND_FE_END | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arnaud-lb just stumbled on this when fixing FPM extension loading using
php_admin_value[extension]
. It actaully usesphp_dl
and initializes permanent module so this is actually not going to work so I had to remove this assertion in #12277 . FPM is single threaded so it should not impact this issue - it just really needs to remove the assertion.There might be potentially other issues with using dl for permanent modules and it has got some limitation but think the whole concept of using php_dl in FPM is really problematic which will require some bigger changes in FPM to get it rif of it (introduction of pool manager).
Anyway if you see some bigger problem with my change, please comment on that PR.