Skip to content

Commit 036eb7c

Browse files
authored
std: remove php_dl() API (#25346)
One can just use php_load_extension() rather than passing a zval* to get the status answer
1 parent 32117fc commit 036eb7c

4 files changed

Lines changed: 10 additions & 22 deletions

File tree

‎UPGRADING.INTERNALS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ PHP 8.7 INTERNALS UPGRADE NOTES
9494
. _php_math_basetozval() now returns zend_result instead of void. It throws
9595
an exception and returns FAILURE if the input contains invalid characters
9696
for the given base.
97+
. php_dl() has been removed, use php_load_extension() instead.
9798

9899
========================
99100
4. OpCode changes

‎ext/standard/dl.c‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ PHPAPI PHP_FUNCTION(dl)
6464
zend_rc_debug = false;
6565
#endif
6666

67-
php_dl(filename, MODULE_TEMPORARY, return_value, 0);
68-
if (Z_TYPE_P(return_value) == IS_TRUE) {
69-
EG(full_tables_cleanup) = 1;
67+
zend_result loaded = php_load_extension(filename, MODULE_TEMPORARY, false);
68+
if (loaded == SUCCESS) {
69+
EG(full_tables_cleanup) = true;
7070
}
7171

7272
#if ZEND_RC_DEBUG
7373
zend_rc_debug = orig_rc_debug;
7474
#endif
75+
RETURN_BOOL(loaded == SUCCESS);
7576
}
7677
/* }}} */
7778

@@ -105,7 +106,7 @@ PHPAPI void *php_load_shlib(const char *path, char **errp)
105106
/* }}} */
106107

107108
/* {{{ php_load_extension */
108-
PHPAPI int php_load_extension(const char *filename, int type, int start_now)
109+
PHPAPI zend_result php_load_extension(const char *filename, int type, bool start_now)
109110
{
110111
void *handle;
111112
char *libpath;
@@ -266,7 +267,7 @@ PHPAPI void *php_load_shlib(const char *path, char **errp)
266267
return NULL;
267268
}
268269

269-
PHPAPI int php_load_extension(const char *filename, int type, int start_now)
270+
PHPAPI zend_result php_load_extension(const char *filename, int type, bool start_now)
270271
{
271272
php_dl_error(filename);
272273

@@ -275,18 +276,6 @@ PHPAPI int php_load_extension(const char *filename, int type, int start_now)
275276

276277
#endif
277278

278-
/* {{{ php_dl */
279-
PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now)
280-
{
281-
/* Load extension */
282-
if (php_load_extension(file, type, start_now) == FAILURE) {
283-
RETVAL_FALSE;
284-
} else {
285-
RETVAL_TRUE;
286-
}
287-
}
288-
/* }}} */
289-
290279
PHP_MINFO_FUNCTION(dl)
291280
{
292281
#if defined(HAVE_LIBDL)

‎ext/standard/dl.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#ifndef DL_H
1818
#define DL_H
1919

20-
PHPAPI int php_load_extension(const char *filename, int type, int start_now);
21-
PHPAPI void php_dl(const char *file, int type, zval *return_value, int start_now);
20+
PHPAPI zend_result php_load_extension(const char *filename, int type, bool start_now);
2221
PHPAPI void *php_load_shlib(const char *path, char **errp);
2322

2423
/* dynamic loading functions */

‎sapi/fpm/fpm/fpm_php.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
6464
int value_len = strlen(value);
6565

6666
if (!strcmp(name, "extension") && *value) {
67-
zval zv;
6867
zend_interned_strings_switch_storage(0);
6968

7069
#if ZEND_RC_DEBUG
@@ -75,14 +74,14 @@ int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode) /* {{{ */
7574
zend_rc_debug = false;
7675
#endif
7776

78-
php_dl(value, MODULE_PERSISTENT, &zv, 1);
77+
zend_result loaded = php_load_extension(value, MODULE_PERSISTENT, true);
7978

8079
#if ZEND_RC_DEBUG
8180
zend_rc_debug = orig_rc_debug;
8281
#endif
8382

8483
zend_interned_strings_switch_storage(1);
85-
return Z_TYPE(zv) == IS_TRUE ? FPM_PHP_INI_EXTENSION_LOADED : FPM_PHP_INI_EXTENSION_FAILED;
84+
return loaded == SUCCESS ? FPM_PHP_INI_EXTENSION_LOADED : FPM_PHP_INI_EXTENSION_FAILED;
8685
}
8786

8887
if (fpm_php_zend_ini_alter_master(name, name_len, value, value_len, mode, PHP_INI_STAGE_ACTIVATE) == FAILURE) {

0 commit comments

Comments
 (0)