diff --git a/lib/accesslib.php b/lib/accesslib.php
index <HASH>..<HASH> 100755
--- a/lib/accesslib.php
+++ b/lib/accesslib.php
@@ -1231,6 +1231,7 @@ function moodle_install_roles() {
                 // ignore site level teacher assignments
                 if ($teacher->course == SITEID) {
                     $progresscount++;
+                    $rs->MoveNext();
                     continue;  
                 }
                 // populate the user_lastaccess table
Killed infinite loop when upgrading teachers!  (merge from stable)