• Resolved NextScripts

    (@nextscripts)


    The WP Engine compatibility checker is throwing up this error:

    FILE: /wp-content/plugins/social-networks-auto-poster-facebook-twitter-g/inc/nxs_snap_class.php
    ———————————————————————————————
    FOUND 1 ERROR AFFECTING 1 LINE
    ———————————————————————————————
    238 | ERROR | Using ‘break’ outside of a loop or switch structure is invalid and will throw a fatal error since PHP 7.0
    ———————————————————————————————

    Line 238:

    foreach ($nxs_snapAvNts as $avNt) 
      if (count($options[$avNt['lcode']])>0) 
        {
          $isNoNts = false; 
          break;
        } 

    So as you can see “break” is properly used INSIDE the “foreach” loop. Your tool just misdiagnosed it because of the “if” statement that it can’t understand.

    This is totally fine PHP syntax, yet your tool can’t recognize it.

    Please fix this. A lot of people are using your tool and complaining that our plugin is not compatible, while it has no issues with PHP 7

    • This topic was modified 8 years, 2 months ago by NextScripts.
    • This topic was modified 8 years, 2 months ago by NextScripts.
    • This topic was modified 8 years, 2 months ago by bdbrown.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Sa?a

    (@stodorovic)

    I already reported similar cases. More info at https://github.com/wimg/PHPCompatibility/issues/292

    Plugin Contributor Jason Stallings

    (@octalmage)

    This has been resolved by v1.3.1. Thanks for the report!

    I run version 1.3.1 and still get this error. The code is:

              foreach ( $this -> controllers as $group => $views_id )
                foreach( $controller_ids as $id )
                  if ( in_array($id, $views_id) ) {
                    $controller_cb = $id;
                    $controller_group = $group;
                    break 2;
                  }//if
                //foreach
              //foreach

    in customizr/core/framework/class-controllers.php

    GermanKiwi

    (@germankiwi)

    Hi, I’m using v1.3.2 of your plugin and also still getting this error as a false positive. I have the WP-Piwik plugin installed, and your plugin is giving me this error:

    FILE: /wp-content/plugins/wp-piwik/classes/WP_Piwik.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
     353 | ERROR | Using 'break' outside of a loop or switch structure is invalid and will throw a fatal error since PHP 7.0
    -------------------------------------------------------------------------------------------------------------------------

    I contacted the WP Piwik plugin author about this (here), and he assured me that there was no error, and that it was a false positive with PHP Compatibility Checker. He said, “the break is not outside a loop – the validator is wrong.”

    Here’s the relevant code from the WP_Piwik.php file:

    foreach ($userRoles as $userRole)
    	if (isset( $allowed[$userRole] ) && $allowed[$userRole]) {
    		$cap = 'read';
    		break;
    }

    Can you please check and fix this, if it’s correct? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘FALSE POSITIVE: Using ‘break’ outside of a loop’ is closed to new replies.