I’m currently working on a lock/unlock feature for editing articles using a webfrontend.
As a reliable technique to unlock articles after editing, closing the brower or leaving the page I developed the following concept:
- Lock the article when accessing the edit page
- Immediately send an AJAX request without timeout to the unlock action
The unlock action has the following code. It is supposed to do nothing until the ajax request has been canceled.
ignore_user_abort(true);
set_time_limit(0);
while (!connection_aborted()) {
usleep(100000);
}
// do database operations to unlock the article
but after the ajax request has been cancelled by ie. leaving the page, it never leaves the while-loop. I also tried this to test for an aborted connection:
while (connection_status() === CONNECTION_NORMAL)
but with the same result, it will never leave the loop.
Quote taken from the PHP Manual
So in your while loop you should send dummy data to the client: