Skip to content

Fix incorrect filename of dl()'d internal consts #16721

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Zend/zend_constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,12 @@ ZEND_API zend_result zend_register_constant(zend_constant *c)
name = c->name;
}

zend_string *filename = zend_get_executed_filename_ex();
if (filename == NULL) {
c->filename = NULL;
} else {
c->filename = zend_string_copy(filename);
c->filename = NULL;
if (ZEND_CONSTANT_MODULE_NUMBER(c) == PHP_USER_CONSTANT) {
zend_string *filename = zend_get_executed_filename_ex();
if (filename) {
c->filename = zend_string_copy(filename);
}
}

/* Check if the user is trying to define any special constant */
Expand Down
2 changes: 2 additions & 0 deletions ext/dl_test/dl_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ PHP_MINIT_FUNCTION(dl_test)
fprintf(stderr, "DL TEST MINIT\n");
}

register_dl_test_symbols(module_number);

return SUCCESS;
}
/* }}} */
Expand Down
3 changes: 3 additions & 0 deletions ext/dl_test/dl_test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
function dl_test_test1(): void {}

function dl_test_test2(string $str = ""): string {}

/** @var int */
const DL_TEST_CONST = 42;
7 changes: 6 additions & 1 deletion ext/dl_test/dl_test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.