diff --git a/packages/php-wasm/compile/php/dns_polyfill.c b/packages/php-wasm/compile/php/dns_polyfill.c index d17c7a8a7c..60466ce607 100644 --- a/packages/php-wasm/compile/php/dns_polyfill.c +++ b/packages/php-wasm/compile/php/dns_polyfill.c @@ -2,6 +2,7 @@ #include "php.h" #include "php_network.h" #include "zend_API.h" +#include "zend_constants.h" #include "dns_polyfill.h" #ifdef HAVE_SYS_SOCKET_H @@ -271,3 +272,24 @@ PHP_FUNCTION(dns_get_mx) RETURN_FALSE; } /* }}} */ + +/* {{{ Polyfill the constants, as PHP won't load them. */ +void register_dns_polyfill_symbols(int module_number) +{ + REGISTER_LONG_CONSTANT("DNS_A", PHP_DNS_A, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_NS", PHP_DNS_NS, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_CNAME", PHP_DNS_CNAME, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_SOA", PHP_DNS_SOA, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_PTR", PHP_DNS_PTR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_HINFO", PHP_DNS_HINFO, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_CAA", PHP_DNS_CAA, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_MX", PHP_DNS_MX, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_TXT", PHP_DNS_TXT, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_SRV", PHP_DNS_SRV, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_NAPTR", PHP_DNS_NAPTR, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_AAAA", PHP_DNS_AAAA, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_A6", PHP_DNS_A6, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_ANY", PHP_DNS_ANY, CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DNS_ALL", PHP_DNS_ALL, CONST_PERSISTENT); +} +/* }}} */ \ No newline at end of file diff --git a/packages/php-wasm/compile/php/dns_polyfill.h b/packages/php-wasm/compile/php/dns_polyfill.h index 5ca609770f..a7cd070913 100644 --- a/packages/php-wasm/compile/php/dns_polyfill.h +++ b/packages/php-wasm/compile/php/dns_polyfill.h @@ -30,4 +30,6 @@ ZEND_END_ARG_INFO() PHP_FUNCTION(dns_get_mx); +void register_dns_polyfill_symbols(int module_number); + #endif // PHP_WASM_DNS_POLYFILL_H \ No newline at end of file diff --git a/packages/php-wasm/compile/php/php_wasm.c b/packages/php-wasm/compile/php/php_wasm.c index 6e5a1790c4..760d2d1f44 100644 --- a/packages/php-wasm/compile/php/php_wasm.c +++ b/packages/php-wasm/compile/php/php_wasm.c @@ -1498,6 +1498,9 @@ int php_wasm_init() php_wasm_sapi_module.php_ini_path_override = phpini_path_override; } + /* Register the DNS Polyfill symbols */ + register_dns_polyfill_symbols(0); + php_sapi_started = 1; php_wasm_sapi_module.additional_functions = additional_functions; if (php_wasm_sapi_module.startup(&php_wasm_sapi_module) == FAILURE) diff --git a/packages/php-wasm/node/public/8_3_0/php_8_3.wasm b/packages/php-wasm/node/public/8_3_0/php_8_3.wasm index dc9a160476..54ab038f02 100755 Binary files a/packages/php-wasm/node/public/8_3_0/php_8_3.wasm and b/packages/php-wasm/node/public/8_3_0/php_8_3.wasm differ diff --git a/packages/php-wasm/node/public/php_8_3.js b/packages/php-wasm/node/public/php_8_3.js index 7e7fafb894..4664d27298 100644 --- a/packages/php-wasm/node/public/php_8_3.js +++ b/packages/php-wasm/node/public/php_8_3.js @@ -1,6 +1,6 @@ const dependencyFilename = __dirname + '/8_3_0/php_8_3.wasm'; export { dependencyFilename }; -export const dependenciesTotalSize = 15331346; +export const dependenciesTotalSize = 15331281; export function init(RuntimeName, PHPLoader) { /** * Overrides Emscripten's default ExitStatus object which gets diff --git a/packages/php-wasm/node/src/test/php.spec.ts b/packages/php-wasm/node/src/test/php.spec.ts index ad0d9fa31a..5b4012b705 100644 --- a/packages/php-wasm/node/src/test/php.spec.ts +++ b/packages/php-wasm/node/src/test/php.spec.ts @@ -196,6 +196,14 @@ describe.each(SupportedPHPVersions)('PHP %s', (phpVersion) => { }); expect(result.text).toEqual('bool(false)\n'); }); + it('DNS_* constants should exist', async () => { + const result = await php.run({ + code: ` { diff --git a/packages/php-wasm/web/public/kitchen-sink/8_3_0/php_8_3.wasm b/packages/php-wasm/web/public/kitchen-sink/8_3_0/php_8_3.wasm index 934f95bdde..866bd339ce 100755 Binary files a/packages/php-wasm/web/public/kitchen-sink/8_3_0/php_8_3.wasm and b/packages/php-wasm/web/public/kitchen-sink/8_3_0/php_8_3.wasm differ diff --git a/packages/php-wasm/web/public/kitchen-sink/php_8_3.js b/packages/php-wasm/web/public/kitchen-sink/php_8_3.js index b94601db87..f03a167f66 100644 --- a/packages/php-wasm/web/public/kitchen-sink/php_8_3.js +++ b/packages/php-wasm/web/public/kitchen-sink/php_8_3.js @@ -1,6 +1,6 @@ import dependencyFilename from './8_3_0/php_8_3.wasm'; export { dependencyFilename }; -export const dependenciesTotalSize = 12837450; +export const dependenciesTotalSize = 12837455; export function init(RuntimeName, PHPLoader) { /** * Overrides Emscripten's default ExitStatus object which gets diff --git a/packages/php-wasm/web/public/light/8_3_0/php_8_3.wasm b/packages/php-wasm/web/public/light/8_3_0/php_8_3.wasm index 65b8ef8fcf..410f7dad8a 100755 Binary files a/packages/php-wasm/web/public/light/8_3_0/php_8_3.wasm and b/packages/php-wasm/web/public/light/8_3_0/php_8_3.wasm differ diff --git a/packages/php-wasm/web/public/light/php_8_3.js b/packages/php-wasm/web/public/light/php_8_3.js index 23d137afc6..1874e37a31 100644 --- a/packages/php-wasm/web/public/light/php_8_3.js +++ b/packages/php-wasm/web/public/light/php_8_3.js @@ -1,6 +1,6 @@ import dependencyFilename from './8_3_0/php_8_3.wasm'; export { dependencyFilename }; -export const dependenciesTotalSize = 5602058; +export const dependenciesTotalSize = 5602049; export function init(RuntimeName, PHPLoader) { /** * Overrides Emscripten's default ExitStatus object which gets