Menu

#90 PHP 7.4 "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?

Release 70
closed
nobody
None
1
2020-12-14
2020-09-24
 
No

I just upgraded a client server from php 5.4 to 7.4 as a prereq for another software and z-push.log/z-push-error.log started to throw:

25/09/2020 01:00:24 [16909] [WARN] [#unknown] /usr/share/z-push/src/backend/zimbra/zimbra.php:3963 "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? (2)

on every sync request.

Note the #unknown can be a username.

So i also upgraded z-push+backend (to master-2.5.2/69) but the warning is still present.

As per the docs https://www.php.net/manual/en/control-structures.continue.php

continue behaves like break (when no arguments are passed) but will raise a warning as this is likely to be a mistake. If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop.

Changing the statement to continue 2 supresses the error seamingly with no adverse effects

--- zimbra.php  2020-09-25 01:43:11.044577376 +0200
+++ zimbra.php.bak      2020-09-25 01:42:58.826547105 +0200
@@ -3960,7 +3960,7 @@
                         // Find The Contact Type And Exclude Contact Groups
                         if (isset($items[$i]['_attrs']['type'])) {
                             if ($items[$i]['_attrs']['type'] == "group") {
-                                continue 2;
+                                continue;
                             }
                         }
                         break;

Cheers

Discussion

  • LiverpoolFCfan

    LiverpoolFCfan - 2020-09-25

    You are correct. This should be doing "continue 2". As the devices just ignores the incomplete contact group item it never flagged up an error before. It will be fixed in Release 70

     
  • LiverpoolFCfan

    LiverpoolFCfan - 2020-10-09

    The fix is in version 69.1 in the Code repository above. Please test and report back if it addresses the issue for you.

     
  • LiverpoolFCfan

    LiverpoolFCfan - 2020-12-10

    Have you had an opportunity to verify the fix in 69.1 yet?

     
  •  

      - 2020-12-10

    Sorry mate, i completely forgot about this.

    Just upgraded the install to master-2.6.0/r260 and everything is working as expected, no more warnings in the logs.

    Cheers

     
  • LiverpoolFCfan

    LiverpoolFCfan - 2020-12-14
    • status: open --> closed
    • Group: unconfirmed --> Release 70
     
  • LiverpoolFCfan

    LiverpoolFCfan - 2020-12-14

    Thanks. Closing ticket.

     

Log in to post a comment.