Skip to content

Commit d613cd6

Browse files
Add MySQL network calls to Asyncify tests (#108)
## Motivation for the change, related issues The [TablePress plugin fails to activate in the Playground CLI and Studio when used with MySQL.](https://linear.app/a8c/issue/STU-60/studio-app-cannot-activate-wordpress-plugins-using-freemius-if-using) I had a hard time finding the missing Asyncify functions, so I ended up adding MySQL network functions to Asycify tests, which helped uncover some MySQL functions in the Asyncify list. ## Implementation details This PR adds missing Asyncify functions required by the TablePress to work with Playground CLI. It also adds support for running Asyncify test and the `fix-asyncify` script with MySQL network function tests by setting MYSQL environment variables. ``` cd packages/php-wasm/node MYSQL_HOST=127.0.0.1 MYSQL_USER=YOUR_USER MYSQL_DATABASE=YOUR_DATABASE MYSQL_PASSWORD=YOUR_PASSWORD ../../../node_modules/.bin/vitest src/test/php-asyncify.spec.ts --watch ``` or ``` MYSQL_HOST=127.0.0.1 MYSQL_USER=YOUR_USER MYSQL_DATABASE=YOUR_DATABASE MYSQL_PASSWORD=YOUR_PASSWORD npm run fix-asyncify ``` ## Testing Instructions (or ideally a Blueprint) - CI --------- Co-authored-by: Brandon Payton <[email protected]>
1 parent ae1f06b commit d613cd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+217
-110
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ jobs:
2626
test-unit-asyncify:
2727
runs-on: wordpress-playground-private
2828
needs: [lint-and-typecheck]
29+
services:
30+
mysql:
31+
image: mysql:5.7
32+
env:
33+
MYSQL_DATABASE: test_db
34+
MYSQL_USER: user
35+
MYSQL_PASSWORD: password
36+
MYSQL_ROOT_PASSWORD: rootpassword
37+
ports:
38+
- 3306:3306
39+
options: >-
40+
--health-cmd="mysqladmin ping --silent"
41+
--health-interval=10s
42+
--health-timeout=5s
43+
--health-retries=3
2944
steps:
3045
- uses: actions/checkout@v4
3146
with:
@@ -34,6 +49,10 @@ jobs:
3449
with:
3550
node-version: 20
3651
- run: node --expose-gc node_modules/nx/bin/nx affected --target=test --configuration=ci
52+
env:
53+
MYSQL_DATABASE: test_db
54+
MYSQL_USER: user
55+
MYSQL_PASSWORD: password
3756
# Most of these tests pass locally but the process is crashing
3857
# on the CI runner.
3958
#

packages/php-wasm/compile/php/Dockerfile

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ RUN export ASYNCIFY_IMPORTS=$'["_dlopen_js",\n\
573573
"dynCall_viiiiiii",\
574574
"dynCall_viiiiiiii",'; \
575575

576-
export ASYNCIFY_ONLY=$'\
576+
export ASYNCIFY_ONLY=$'"object_init_ex",\
577577
"zif_exif_imagetype",\
578578
"zif_exif_read_data",\
579579
"zif_exif_thumbnail",\
@@ -616,6 +616,11 @@ export ASYNCIFY_ONLY=$'\
616616
"Curl_ssl_connect_nonblocking",\
617617
"https_connecting",\
618618
"Curl_readwrite",\
619+
"zend_fetch_debug_backtrace",\
620+
"zend_default_exception_new",\
621+
"zend_throw_exception_zstr",\
622+
"zend_throw_exception",\
623+
"zend_type_error",\
619624
"zend_generator_iterator_move_forward",\
620625
"ZEND_FE_FETCH_R_SPEC_VAR_HANDLER",\
621626
"zend_generator_resume",\
@@ -624,6 +629,7 @@ export ASYNCIFY_ONLY=$'\
624629
"ZEND_FE_RESET_R_SPEC_VAR_HANDLER",\
625630
"zend_user_it_get_new_iterator",\
626631
"ZEND_ADD_ARRAY_UNPACK_SPEC_HANDLER",\
632+
"ZEND_COUNT_SPEC_CV_UNUSED_HANDLER",\
627633
"__fwritex",\
628634
"read",\
629635
"zif_sleep",\
@@ -707,6 +713,11 @@ export ASYNCIFY_ONLY=$'\
707713
"ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_CV_TMPVAR_HANDLER",\
708714
"ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMPVAR_CONST_HANDLER",\
709715
"ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC_TMPVAR_HANDLER",\
716+
"ZEND_ASSIGN_OBJ_SPEC_VAR_CV_OP_DATA_CV_HANDLER",\
717+
"ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_DATA_CV_HANDLER",\
718+
"ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_DATA_VAR_HANDLER",\
719+
"ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_DATA_TMP_HANDLER",\
720+
"ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_OP_DATA_CONST_HANDLER",\
710721
"cli",\
711722
"wasm_sleep",\
712723
"wasm_php_stream_flush",\
@@ -758,6 +769,9 @@ export ASYNCIFY_ONLY=$'\
758769
"mysqlnd_mysqlnd_command_handshake_pub",\
759770
"mysqlnd_mysqlnd_command_init_db_pub",\
760771
"mysqlnd_mysqlnd_command_reap_result_pub",\
772+
"mysqlnd_mysqlnd_command_set_option_pub",\
773+
"mysqlnd_mysqlnd_command_ping_pub",\
774+
"mysqlnd_mysqlnd_conn_data_ping_pub",\
761775
"mysqlnd_mysqlnd_conn_connect_pub",\
762776
"mysqlnd_mysqlnd_conn_data_connect_handshake_pub",\
763777
"mysqlnd_mysqlnd_conn_data_connect_pub",\
@@ -766,11 +780,13 @@ export ASYNCIFY_ONLY=$'\
766780
"mysqlnd_mysqlnd_conn_data_reap_query_pub",\
767781
"mysqlnd_mysqlnd_conn_data_select_db_pub",\
768782
"mysqlnd_mysqlnd_conn_data_set_charset_pub",\
783+
"mysqlnd_mysqlnd_conn_data_set_server_option_pub",\
769784
"mysqlnd_mysqlnd_conn_data_store_result_pub",\
770785
"mysqlnd_mysqlnd_conn_data_tx_commit_or_rollback_pub",\
771786
"mysqlnd_mysqlnd_pfc_receive_pub",\
772787
"mysqlnd_mysqlnd_pfc_send_pub",\
773788
"mysqlnd_mysqlnd_protocol_send_command_handle_OK_pub",\
789+
"mysqlnd_mysqlnd_protocol_send_command_handle_EOF_pub",\
774790
"mysqlnd_mysqlnd_protocol_send_command_handle_response_pub",\
775791
"mysqlnd_mysqlnd_protocol_send_command_pub",\
776792
"mysqlnd_mysqlnd_res_store_result_fetch_data_pub",\
@@ -904,6 +920,7 @@ export ASYNCIFY_ONLY=$'\
904920
"zend_parse_va_args",\
905921
"zend_std_call_getter",\
906922
"zend_std_has_property",\
923+
"zend_parse_method_parameters",\
907924
"zend_std_read_property",\
908925
"zif_array_map",\
909926
"zif_array_reduce",\
@@ -919,8 +936,10 @@ export ASYNCIFY_ONLY=$'\
919936
"zif_fread",\
920937
"zif_fsockopen",\
921938
"zif_getimagesize",\
939+
"zif_mysqli_ping",\
922940
"zif_mysqli_begin_transaction",\
923941
"zif_mysqli_connect",\
942+
"zif_mysqli_link_construct",\
924943
"zif_mysqli_data_seek",\
925944
"zif_mysqli_errno",\
926945
"zif_mysqli_error",\
@@ -967,6 +986,7 @@ export ASYNCIFY_ONLY=$'\
967986
"zim_reflection_class_newInstanceArgs",\
968987
"zim_reflection_method_invoke",\
969988
"zim_reflection_method_invokeArgs",\
989+
"zim_mysqli___construct",\
970990
"ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER",\
971991
"ZEND_NEW_SPEC_CONST_UNUSED_HANDLER",\
972992
"compile_file",\
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

packages/php-wasm/node/asyncify/php_7_2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const require = createRequire(import.meta.url);
66
const __dirname = new URL('.', import.meta.url).pathname;
77
const dependencyFilename = __dirname + '/7_2_34/php_7_2.wasm';
88
export { dependencyFilename };
9-
export const dependenciesTotalSize = 15162253;
9+
export const dependenciesTotalSize = 15174064;
1010
export function init(RuntimeName, PHPLoader) {
1111
// The rest of the code comes from the built php.js file and esm-suffix.js
1212
// include: shell.js

packages/php-wasm/node/asyncify/php_7_3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const require = createRequire(import.meta.url);
66
const __dirname = new URL('.', import.meta.url).pathname;
77
const dependencyFilename = __dirname + '/7_3_33/php_7_3.wasm';
88
export { dependencyFilename };
9-
export const dependenciesTotalSize = 15253952;
9+
export const dependenciesTotalSize = 15264356;
1010
export function init(RuntimeName, PHPLoader) {
1111
// The rest of the code comes from the built php.js file and esm-suffix.js
1212
// include: shell.js

packages/php-wasm/node/asyncify/php_7_4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const require = createRequire(import.meta.url);
66
const __dirname = new URL('.', import.meta.url).pathname;
77
const dependencyFilename = __dirname + '/7_4_33/php_7_4.wasm';
88
export { dependencyFilename };
9-
export const dependenciesTotalSize = 15755852;
9+
export const dependenciesTotalSize = 15767571;
1010
export function init(RuntimeName, PHPLoader) {
1111
// The rest of the code comes from the built php.js file and esm-suffix.js
1212
// include: shell.js

packages/php-wasm/node/asyncify/php_8_0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const require = createRequire(import.meta.url);
66
const __dirname = new URL('.', import.meta.url).pathname;
77
const dependencyFilename = __dirname + '/8_0_30/php_8_0.wasm';
88
export { dependencyFilename };
9-
export const dependenciesTotalSize = 14877700;
9+
export const dependenciesTotalSize = 14885873;
1010
export function init(RuntimeName, PHPLoader) {
1111
// The rest of the code comes from the built php.js file and esm-suffix.js
1212
// include: shell.js

packages/php-wasm/node/asyncify/php_8_1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const require = createRequire(import.meta.url);
66
const __dirname = new URL('.', import.meta.url).pathname;
77
const dependencyFilename = __dirname + '/8_1_23/php_8_1.wasm';
88
export { dependencyFilename };
9-
export const dependenciesTotalSize = 14857616;
9+
export const dependenciesTotalSize = 14866086;
1010
export function init(RuntimeName, PHPLoader) {
1111
// The rest of the code comes from the built php.js file and esm-suffix.js
1212
// include: shell.js

0 commit comments

Comments
 (0)