Jump to content

Recommended Posts

Hey everyone,

 

I have a plugin for a CMS that searches out multiple "archives" of articles and then sorts/limits (according to whatever the user says) then displays them as one array.  One of the users has had a problem with an error:

 

Fatal error: Maximum execution time of 30 seconds exceeded in /usr/home/web/user/frog/plugins/adv-find/index.php on line 45

 

The offending lines are:

 

<?php
private function trimc($limit)
{
	$this->children = array_slice($this->children, 0, $limit); //Line 45
}
?>

 

The whole class is:

 

<?php

Plugin::setInfos(array(
    'id'          => 'adv-find',
    'title'       => 'Advanced Find', 
    'description' => 'Allows you to search many different archives and sort them by date.', 
    'version'     => '1.0.1',
    'license'     => 'AGPL',
    'author'      => 'Tyler Beckett',
    'website'     => 'http://www.tbeckett.net/articles/plugins/adv-find.xhtml',
    'update_url'  => 'http://www.tbeckett.net/fpv.xhtml',
    'require_frog_version' => '0.9.4'
));

error_reporting(E_ALL^E_NOTICE);

class adv_find extends Page
{
private $search;
private $vars;
private $sortAttribute;

public $children;

private function sorty($attribute) 
{
	$this->sortAttribute = $attribute;
	usort($this->children, array($this, 'cmpVals'));
}
     
private function cmpVals($val1, $val2) 
{
	$search = $this->sortAttribute['0'];
	$order = $this->sortAttribute['1'];

	if (strtoupper($order) == 'DESC')
	{
		return (strcasecmp($val1->$search, $val2->$search)*-1);
	}
	return strcasecmp($val1->$search, $val2->$search);
}

private function trimc($limit)
{
	$this->children = array_slice($this->children, 0, $limit);
}

public function adv_where($search, $vars)
{
	// Use Frog's built in find function to search for each of the arguments provided
	foreach ($search as $sought)
	{
		$results[] = parent::find($sought);
	}

	// Use Frog's built in children function to get all children of the above searched for archives
	foreach ($results as $parent)
	{
		$children[] = $parent->children($vars);
	}

	// Count the number of archive variables in the array
	$total = count($children);

	// Count the number of children variables to each of the archive variables above
	for ($x = 0; $x <= $total; $x++)
	{
		$ctotal[$x] = count($children[$x]);
	}

	// Combine all the search results into one $combine variable
	$combine = array();
	for ($x = 0; $x < $total; $x++)
	{
		for ($y = 0; $y < $ctotal[$x]; $y++)
		{
			array_unshift($combine,$children[$x][$y]);
		}
	}
	unset($children);
	$this->children = $combine;
	unset($combine);

	// If the user has chosen an order that they'd like the results in, order like so
	if (isset($this->vars['order']))
	{
		$sve = explode(' ', $this->vars['order']);
		adv_find::sorty($sve);
	}

	// If the user wants to limit their results, trim the remaining off
	if (isset($this->vars['limit']))
	{
		adv_find::trimc($this->vars['limit']);
	}

	return $this->children;
}

public function __construct($search,$vars)
{
	// Instantiate all the variables necessary to do the search
	$this->search = $search;
	$this->vars = $vars;

	// Do the search and then save the results to $this->results
	$this->results = $this->adv_where($this->search,$this->vars);
}
}

function adv_find($query, $args = '')
{
// Begin the process
$found = new adv_find($query, $args);

// Pass the results back to the user!
return $found->children;
}

?>

 

I cannot, for the life of me, figure out why he'd have a max execution time problem.  I currently display 16 articles on my RSS feed with no problems.  Can anyone else here point me in a possible direction?  Could it just be the user's server?

 

Thanks in advance for any help.

Link to comment
https://forums.phpfreaks.com/topic/131895-max-execution-time-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.