• Resolved Iamdez

    (@iamdez)


    I have the following rules setup (multi-site setup, but not network activated)

    Show Content:
    M-F 5:00am – 10:46am run weekly until 2020 (that year can change if necessary)

    Hide Content:
    M-F 12:00am – 4:59am run weekly until 2020
    M-F 10:46am – 11:59pm run weekly until 2020
    Sat-Sun 12:00am – 11:59pm run weekly until 2020

    When I put just two of the rules (show & sat/sun rule on my home page) I hit the maximum execution time for php of 30 seconds.

    [Sun Dec 01 01:43:08 2013] [error] [client 127.0.0.1] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /path/to/www-docroot/wp-content/plugins/timed-content/timed-content.php on line 161, referer: http://mypage.com

    http://wordpress.org/plugins/timed-content/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor K. Tough

    (@kjvtough)

    Hi, Iamdez.

    I can replicate the bug. Let me take a look and see what’s going on. Are you finding the Scheduled Dates/Times coming up relatively quickly on the back end?

    Thread Starter Iamdez

    (@iamdez)

    Yeah, they take about 5 seconds to show all of the dates set out from now until expiration. If I’m reading you correctly you’re talking about the button on the rule setup page that shows me the list of dates/times that the rule is in effect for.

    Plugin Contributor K. Tough

    (@kjvtough)

    Yep, that’s what I was referring to.

    I think I found the problem: the array of days of the week was being set up differently depending on whether you were checking the scheduled dates on the back-end or loading them from the rule settings. If you’re comfortable with copying/pasting code, you can try replacing the __getNextWeek function with the following code:

    function __getNextWeek( $current, $interval_multiplier, $days = array() )  {
    	if ( empty( $days ) ) return strtotime( $interval_multiplier . " week", $current );
    
    	$currentDayOfWeekIndex = date( "w", $current );
    	sort( array_values( array_unique( array_merge( array( $currentDayOfWeekIndex ), $days ) ) ) );
    	$daysOfWeek = array_combine( $days, $days );
    	if ( $currentDayOfWeekIndex == max( $daysOfWeek ) )
    		$pattern = ( ( 7 - $currentDayOfWeekIndex ) + ( 7 * ( $interval_multiplier - 1 ) ) + ( min( array_keys( $daysOfWeek ) ) ) ) . " day";
    	else  {
    		$nextDayOfWeekIndex = $currentDayOfWeekIndex;
    		do {} while ( !isset( $daysOfWeek[++$nextDayOfWeekIndex] ) );
    		$pattern = ( $nextDayOfWeekIndex - $currentDayOfWeekIndex ) . " day";
    	}
    	return strtotime( $pattern, $current );
    }

    Let me know if this works for you; it seems to fix the issue here. If it doesn’t blow up horribly, I’ll be pushing out an update in the next day or 2.

    -K

    Thread Starter Iamdez

    (@iamdez)

    I replaced the function wholly and it seems to be working.

    I did get the following when I activated the plugin, though

    [Sun Dec 01 14:46:01 2013] [error] [client 127.0.0.1] PHP Warning: Invalid argument supplied for foreach() in /wp-content/plugins/timed-content/timed-content.php on line 656, referer: http://mysite.org/wp-admin/plugins.php

    Thread Starter Iamdez

    (@iamdez)

    Marking this as resolved.

    Plugin Contributor K. Tough

    (@kjvtough)

    Glad that worked for you, and thanks for the heads-up on the activation warning. I’ll see what’s going on there.

    -K

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Maximum Execution time reached’ is closed to new replies.