From 69bcdef53139e4952bfd2e027ee85c720a836e35 Mon Sep 17 00:00:00 2001
From: Steven Wittens <steven@10.no-reply.drupal.org>
Date: Wed, 21 Dec 2005 23:44:08 +0000
Subject: [PATCH] - JS Updater: stop monitoring progress when 100% is reached
 (can lead to infinite refresh loops in Safari)

---
 misc/progress.js |  4 ++--
 misc/update.js   | 11 ++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/misc/progress.js b/misc/progress.js
index 66013d4e88e4..e7c289e317e9 100644
--- a/misc/progress.js
+++ b/misc/progress.js
@@ -42,7 +42,7 @@ progressBar.prototype.setProgress = function (percentage, status) {
     }
   }
   if (this.callback) {
-    this.callback(percentage, status);
+    this.callback(percentage, status, this);
   }
 }
 
@@ -82,8 +82,8 @@ progressBar.prototype.receivePing = function (string, xmlhttp, pb) {
   }
   // Split into values
   var matches = string.length > 0 ? string.split('|') : [];
+  pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
   if (matches.length >= 2) {
     pb.setProgress(matches[0], matches[1]);
   }
-  pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
 }
diff --git a/misc/update.js b/misc/update.js
index e4358d269172..117713b69aa7 100644
--- a/misc/update.js
+++ b/misc/update.js
@@ -5,16 +5,17 @@ if (isJsEnabled()) {
     }
 
     if ($('progress')) {
-      updateCallback = function (progress, status) {
+      updateCallback = function (progress, status, pb) {
         if (progress == 100) {
+          pb.stopMonitoring();
           window.location = window.location.href.split('op=')[0] +'op=finished';
         }
       }
 
-      this.progress = new progressBar('updateprogress', updateCallback, HTTPPost);
-      this.progress.setProgress(-1, 'Starting updates...');
-      $('progress').appendChild(this.progress.element);
-      this.progress.startMonitoring('update.php?op=do_update', 0);
+      var progress = new progressBar('updateprogress', updateCallback, HTTPPost);
+      progress.setProgress(-1, 'Starting updates...');
+      $('progress').appendChild(progress.element);
+      progress.startMonitoring('update.php?op=do_update', 0);
     }
   });
 }
-- 
GitLab