Skip to content
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

PHP: Allow overwriting the quit option in emscriptenOptions #937

Merged
merged 1 commit into from
Jan 12, 2024
Merged

PHP: Allow overwriting the quit option in emscriptenOptions #937

merged 1 commit into from
Jan 12, 2024

Conversation

mho22
Copy link
Contributor

@mho22 mho22 commented Jan 12, 2024

What is this PR doing?

Based on the issue #926

By default, even if you add a quit method in emscryptenOptions :

const php = await NodePHP.load( '8.2', { emscriptenOptions : { quit : ( status, toThrow ) => { if( status === 0 ){ process.exit() } return toThrow } } } );

it is overwritten by the actual one on line 57 in node-php.ts :

quit: function (code, error) {
	throw error;
},

This PR is moving this template callback to be overwritten by emscryptenOptions object given by user.

What problem is it solving?

To avoid throwing error from php.exit() even if it is exiting quietly.

Testing Instructions

const php = await NodePHP.load( '8.2', emscriptenOptions : { quit : ( status, toThrow ) => { if( status === 0 ){ process.exit() } return toThrow } } } );

php.exit(0);

This should display nothing.

@adamziel
Copy link
Collaborator

Thank you so much @mho22 !

@adamziel adamziel merged commit 4669959 into WordPress:trunk Jan 12, 2024
5 checks passed
@adamziel adamziel changed the title Quit callback overwrites the quit callback template PHP: Allow overwriting the quit option in emscriptenOptions Jan 12, 2024
@mho22 mho22 deleted the quit-callback-patch branch January 12, 2024 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants