Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mudrd8mz opened this issue Dec 3, 2016 · 2 comments
Open

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

mudrd8mz opened this issue Dec 3, 2016 · 2 comments

Comments

@mudrd8mz
Copy link

mudrd8mz commented Dec 3, 2016

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
Copy link
Author

mudrd8mz commented Dec 3, 2016

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
Copy link
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant