diff --git a/packages/php-wasm/compile/php/dns_polyfill.c b/packages/php-wasm/compile/php/dns_polyfill.c index d17c7a8a7c..90bcf6e69c 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,26 @@ PHP_FUNCTION(dns_get_mx) RETURN_FALSE; } /* }}} */ + +/* {{{ Polyfill the constants, as PHP won't load them. */ +PHP_MINIT_FUNCTION(dns_polyfill) +{ + 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); + + return SUCCESS; +} +/* }}} */ \ No newline at end of file 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..0f817f1511 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..05fc0ef65a 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