2

I'm trying to debug an issue with some PHP/MySQL/jQuery code that handles pessimistic locking. It uses two fields: locking_user_id and locking_date_time. The locking is determined by an AJAX action to PHP/MySQL. The jQuery code below shows the typical update for the locking which occurs every 15 seconds. There's also a save action every 10 minutes.

My question is, what happens to the jQuery/Locking Update when someone's computer goes into "sleep mode" or is "locked" for a few hours? Will the AJAX call continue? I assume the setTimeout() no longer runs? One person is knowingly allowing edit views to remain open for hours at a time. I'm fairly certain this is causing the issue were seeing. I'm building in additional PHP validation checks on update, today.

Does anyone have any suggestions to make the Edit View "timeout" based on inactivity?

<script>

// Automatically Save Every 10 Minutes
setInterval(submit_crudForm, 600000); // (1000 * 60 * 10 = 600000)

function submit_crudForm() {
    $('#crudForm').submit();
}

// Set Update Locking
function updateLockingCount () {
    $.getJSON('https://wwww.thedomain.com/catalog/ajax_update_locking/1004', function(data) {
        //console.log(data);
        setTimeout(updateLockingCount, 15*1000);
    });
}
$(function () {
    updateLockingCount();
});

Related Post: PHP/MySQL/jQuery Pessimistic Locking of Record

Community
  • 1
  • 1
jjwdesign
  • 3,272
  • 8
  • 41
  • 66
  • 1
    Interesting question. When your computer is sleeping it won't execute and there won't be a timeout on the clientside so you'd have to manage it on the server. I locked my win 7 machine and chrome continued to execute a setInterval while locked. I'm not sure what other OS's would do or how long it would continue to execute. – lucuma Apr 22 '13 at 19:39
  • If it's a interesting question, then vote it up please. I decided to add some more server side validation. You just can't rely on client side validation these days. – jjwdesign Apr 22 '13 at 20:08

0 Answers0