Wordpress plugin/PHP functions - exceeding max exec time

Discussion in 'Web Design and Development' started by cleo, Oct 5, 2008.

  1. cleo macrumors 65816


    Jan 21, 2002
    Tampa Bay Area, FL, USA
    I'm writing a WordPress plugin that is also my first foray into writing my own PHP functions. (I've been using PHP for 6 years, but was always too intimidated to try my hand at custom functions.)

    Anyway, it's pretty simple, and sometimes works fine, but more often than not I get the following error:

    Fatal error: Maximum execution time of 30 seconds exceeded in /home/gobecky/public_html/gobecky-net/wordpress/wp-includes/plugin.php on line 274
    The script referenced is one of the core WP files, and I haven't touched it in any way. It's clear that it's my plugin, though, because removing the function call lets the page load just fine.

    For the sake of a short post, here's a link to my script: plugin.txt

    And here's how I'm calling it:

    prevNextByCat('','','<div class=\'chunk\'><ul>','</ul></div>','<h3><span>Browse</span> / in ','</h3>');
    Any insight would be much appreciated!
  2. SrWebDeveloper macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA
    Ugh, what awful plugin code (my .02) - let me explain:

    The plugin checks all your categories against the current post running two relatively complex queries for category if a match is made or not. It should probably be running one consolidated query, not returning all fields (only what is needed) in the result set and those pesky left joins might not even be required - that slows things down right there. I cannot suggest a new query or code because I don't use wordpress, I'm just reporting to you that looping through stuff with two bloated queries on every page load is always wrong, no matter the application or context.

    I suggest you find another version of the plugin that works better or code your own solution. Maybe some wordpress guru can help ya. I'm just pointing out the "why" although I can't code a "fix" as I am unfamiliar with the entire database structure and overall code base.

  3. SC68Cal macrumors 68000

    Feb 23, 2006

Share This Page