SVIeSolutions / moodle-mod_via

1 stars 2 forks source link

Fatal error: 'continue' not in the 'loop' or 'switch' context #6

Open mudrd8mz opened 7 years ago

mudrd8mz commented 7 years ago
Fatal error: 'continue' not in the 'loop' or 'switch' context in /mod/via/lib.php on line 1130

The plugin makes the site die in PHP7. This is serious.

mudrd8mz commented 7 years ago

This seems to help, but you should carefully review the usage of the continue statement in your code.

--- lib.php.origin  2016-12-03 11:32:27.798938236 +0100
+++ lib.php 2016-12-03 11:33:51.613937618 +0100
@@ -1126,8 +1126,7 @@
     if (!$DB->update_record('via', $record)) {
         // If this fails, stop everything to avoid sending a bunch of dupe emails.
         echo "    Could not update via table!\n";
-        $result = false;
-        continue;
+        return false;
     }

     return $result;
@@ -1155,8 +1154,7 @@
         $from = via_get_host($i->activityid);

         if (!$muser) {
-            $result = false;
-            continue;
+            return false;
         }

         // Send reminder.
@@ -1164,8 +1162,7 @@
             $result = via_send_moodle_invitations($i, $muser, $from);
         } catch (Exception $e) {
             notify(get_string("error:".$e->getMessage(), "via"));
-            $result = false;
-            continue;
+            return false;
         }
     }

@@ -1352,8 +1349,7 @@
     if (!isset($muser->emailstop) || !$muser->emailstop) {
         if (true !== email_to_user($user, $from, $subject, $body, $bodyhtml)) {
             echo "    Could not send email to <{$user->email}> (unknown error!)\n";
-            $result = false;
-            continue;
+            return false;
         }
     }

@@ -1364,8 +1360,7 @@
     if (!$DB->update_record('via', $record)) {
         // If this fails, stop everything to avoid sending a bunch of dupe emails.
         echo "    Could not update via table!\n";
-        $result = false;
-        continue;
+        return false;
     }

     return $result;
SVIeSolutions commented 7 years ago

Hi, I have added a new version that fixes these 'loop' issues. I will also look into the PHP 7 compitability issue!!! Thanks for mentioning it!