From b7781ead216e9678d1430e5da331e148bdd64c57 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Thu, 28 Jun 2012 00:06:57 -0400 Subject: [PATCH] Change HTTP header code from 304 to 201, Add random query string on reload --- include/ajax.upgrader.php | 11 ++++++++--- scp/js/upgrader.js | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/ajax.upgrader.php b/include/ajax.upgrader.php index 1582b7a8c..41100b9d3 100644 --- a/include/ajax.upgrader.php +++ b/include/ajax.upgrader.php @@ -34,10 +34,15 @@ class UpgraderAjaxAPI extends AjaxController { exit; } + if($upgrader->isAborted()) { + Http::response(416, "We have a problem ... wait a sec."); + exit; + } + if($upgrader->getNumPendingTasks()) { if($upgrader->doTasks() && !$upgrader->getNumPendingTasks() && $ost->isUpgradePending()) { - //Just reporting done...with tasks - break in between patches! - header("HTTP/1.1 304 Not Modified"); + //Just reporting done...with tasks - break in between patches with scripted tasks! + Http::response(201, "TASKS DONE!"); exit; } } elseif($ost->isUpgradePending() && $upgrader->isUpgradable()) { @@ -50,7 +55,7 @@ class UpgraderAjaxAPI extends AjaxController { } elseif(!$ost->isUpgradePending()) { $upgrader->setState('done'); session_write_close(); - header("HTTP/1.1 304 Not Modified"); + Http::response(201, "DONE!"); exit; } diff --git a/scp/js/upgrader.js b/scp/js/upgrader.js index 8c39b73fe..09bde7766 100644 --- a/scp/js/upgrader.js +++ b/scp/js/upgrader.js @@ -42,14 +42,14 @@ jQuery(function($) { setTimeout(function() { _lp(count+1); }, 2); }, - 304: function() { + 201: function() { $('#loading #msg').html("We're done... cleaning up!"); - setTimeout(function() { location.href =url;}, 3000); + setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 3000); } }, error: function() { $('#loading #msg').html("Something went wrong"); - setTimeout(function() { location.href =url;}, 1000); + setTimeout(function() { location.href =url+'?c='+count+'&r='+Math.floor((Math.random()*100)+1); }, 1000); } }); }; -- GitLab