Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author anmari

    (@anmari)

    Hi Brent, thanks for the heads up. Always good to future proof code. and you made me check what else is changing in php 7!

    That particular piece of code was lifted straight out of wp’s sidebar code in wp-includes/widgets.php (currently round about line 1188 of the WordPress 4.2-beta4-32059 ),so it looks like it’s more than just this plugin that will be needing some changes for php 7.0 ??

    With some quick googling I couldn’t find out if there was a reasonable stable version to run on a wamp install – any advice? since you must be in the ‘know’ ?

    Thread Starter BrentNewland

    (@brentnewland)

    I had to ask online to find the PHP 7 nightly snapshots are here https://windows.php.net/snapshots/ at the bottom under “Master”. I converted two WordPress installations to it and it’s much faster. If you’re using PHP in FastCGI mode, I’d recommend the x64 Non-Thread-Safe build.

    On my server, using nginx (for now), it’s pretty easy to configure PHP per domain. I have PHP5 running as one Windows service (for our server’s Owncloud), and another PHP7 service for our WordPress sites. Here’s a guide I wrote on installing PHP as a Windows service: https://forum.nginx.org/read.php?2,236376,236376

    Though our current WinSW FastCGI configuration code looks like this:

    <service>
      <id>PHP7</id>
      <name>PHP7</name>
      <description>This service handles the primary PHP7 FastCGI server.</description>
      <executable>C:\server\php7\php-cgi.exe</executable>
      <arguments>-b 9127 -c c:\server\php7\php.ini</arguments>
      <env name="InstanceMaxRequests" value="0" />
      <env name="pm.max_requests" value="0" />
      <env name="PHP_FCGI_MAX_REQUESTS" value="0" />
      <stopexecutable>C:\SERVER\php7\php-stop.cmd</stopexecutable>
      <logpath>C:\server\logs\php7</logpath>
      <log mode="roll-by-size">
        <sizeThreshold>256</sizeThreshold>
        <keepFiles>128</keepFiles>
      </log>
    </service>

    And php-stop.cmd consists of just “taskkill /f /IM php-cgi.exe”

    Anyways, back to the topic, looking at the WordPress code, it appears the problem is that the code used in WordPress’s widgets.php is in a foreach loop. The immediate preceding code from widgets.php:

    foreach ( (array) $sidebars_widgets[$index] as $id ) {

    However, your script’s code does not have a foreach loop, therefore “continue” is not correct for that location. Continue is for use in loops only. https://php.net/manual/en/control-structures.continue.php I’m pretty sure, right now, that if statement does nothing.

    I think change:

    if ( !isset($wp_registered_widgets[$widget_id]) ) continue;
    
    		$params = array_merge(
    			array(
    				array_merge( $sidebar,
    					array('widget_id' => $widget_id,
    						'widget_name' => $wp_registered_widgets[$widget_id]['name']) ) ),
    						(array) $wp_registered_widgets[$widget_id]['params']
    		);

    to

    if ( !isset($wp_registered_widgets[$widget_id]) ) {
    
    		$params = array_merge(
    			array(
    				array_merge( $sidebar,
    					array('widget_id' => $widget_id,
    						'widget_name' => $wp_registered_widgets[$widget_id]['name']) ) ),
    						(array) $wp_registered_widgets[$widget_id]['params']
    		);
    	}
    Plugin Author anmari

    (@anmari)

    Hi re code : actually if the id is not in the set of registered widgets we just want to exit, not do anything, which I guess I was thinking the continue would do as it does in the loop – skip to the next bit of code. BUT Actually the code should never have executed as the situation of not a valid id gets trapped before that!

    any way – thanks for info

    With some quick googling I couldn’t find out if there was a reasonable stable version to run on a wamp install – any advice?

    Just in case you haven’t found a good way to test PHP 7 yet, it’s now available by default on servers configured by ServerPilot. So, you can use a $5/month DigitalOcean server, connect it to ServerPilot, use ServerPilot’s one-click WordPress install, and test your plugin on PHP 7. DigitalOcean actually bills hourly and ServerPilot has a free plan, so it won’t cost much to test that way.

    @anmari: Any update about this issue? I’m having the same problem with this plugin and can’t find how to solve this..

    Plugin Author anmari

    (@anmari)

    jfb
    please upgrade to 2.9.

    The current version does not use ‘continue’ anywhere, so it will not be possible to have this same problem
    “PHP Fatal error: ‘continue’ not in the ‘loop’ or ‘switch’ context”

    if your problem is actually something else to do with this plugin and not the widgets you are using, please post a new topic

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP 7 Compatibility’ is closed to new replies.