kphp
kphp copied to clipboard
add function ignore_user_abort
Add a new function ignore_user_abort analogue from PHP
Introduction
ignore_user_abort — Set whether aborting should abort script execution. This implementation matches the description here with one exception unlike the implementation in PHP, the current version considers the nesting level and does not complete the script until it becomes zero
Description
ignore_user_abort(?bool $enable = null): int
-
Parameter List Takes a flag value and sets it with the appropriate nesting level change. If the argument is null, then returns the current level without changing it
-
Return Values Return nesting level previous value
Usage
function important_work(...) {
ignore_user_abort(true);
...
ignore_user_abort(false);
// start critical section which will be executed regardless of the state of the connection
ignore_user_abort(true);
important_work(...);
// some other work to be carried out as rpc, resumable or function calls
ignore_user_abort(false);
// termination of the script if the connection was interrupted
Testing
This pr also contains tests to check the correct operation of the server using this function