I get the following error occasionally when the sitemap is accessed:

PHP Fatal error: Maximum execution time of 40 seconds exceeded in /usr/local/apache2/vhosts/kpbj.com/htdocs/sites/all/modules/xmlsitemap/xmlsitemap.pages.inc on line 198

Comments

apaderno’s picture

Title: Maximum PHP Execution Time Reached » PHP timeout while executing xmlsitemap.pages.inc

You didn't say it, but I guess you get that error when you are watching the sitemap content.

How many nodes do you have in your site? Take in consideration that branch 6.x-1 is not actually thought for sites with a high number of nodes, or user profiles (in the case you activated xmlsitemap_user.module too).

Anonymous’s picture

Category: bug » support
Status: Active » Fixed

PHP's maximum execution time is a php configurable item. You simple have more rows in the xmlsitemap file than can be processed in 40 seconds on your server. You can add the following line to the end of your .htaccess file that may help depending on restrictions placed by your host.

php_value maximum_execution_time 240

Adjust the 240 as you see fit.

gregarios’s picture

I raised the max execution time in my PHP.ini file on the server instead, and it seems to have fixed it for now. I have about 4000 nodes and 1500 user accounts. Is that a lot? Seems so.

How stable is the Dev 6.x-2.x branch? Would it work well for me? I'm only using the "node" and "user" portion of the module, but could give up the "user" one if the 2.x branch doesn't have it yet.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

afagioli’s picture

Issue tags: +timeout

Since PHP let us set timeput at runtime , [ http://php.net/manual/en/function.set-time-limit.php ]
I'd love to have that at the top of the

function _xmlsitemap_output($chunk = NULL) 

xmlsitemap.module:336, with a proper setting in the admin/settings/xmlsitemap page

Example:

/**
 * Menu callback; display the site map.
 * @param $chunk:
 * An integer specifying which chunk of the site map is being requested. If
 * not set and there is more than one chunk, display the site map index.
 * @return None
 */
function _xmlsitemap_output($chunk = NULL) {
  set_time_limit ( XMLSITEMAP_MY_TIMEOUT ) ;
  drupal_set_header('Content-type: text/xml; charset=utf-8');
  .....etc etc

This solution helped with a very large website

afagioli’s picture

Category: support » feature
Status: Closed (fixed) » Needs review
Dave Reid’s picture

Version: 6.x-1.0-beta6 » 7.x-2.x-dev
Component: xmlsitemap_node.module » xmlsitemap.module
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

j0rd’s picture

Status: Closed (fixed) » Needs work

There's a problem with hardcoding the limit to 240. I have 40k+ nodes on my site and I'm trying to generate the xmlsitemap via drush....but it's failing after 240 seconds.

With this code, http://drupalcode.org/project/xmlsitemap.git/commitdiff/195b668?hp=fc45a... you need to check to see if max execution time is set lower than 240 seconds, then increase it. Not decrease it, if it's already larger.

This becomes very difficult to debug, as php, drush and now xmlsitemap all attempt to tweak this setting.

Here's an example of how to properly set this from some drush code

  $max_execution_time = ini_get('max_execution_time'); 
  if ($max_execution_time > 0 && $max_execution_time < 240) {
    set_time_limit(240); 
  }
bibo’s picture

We encountered the same problem as j0rd. The fix in #7 actually makes things worse when using drush.

Drush follows PHP cli (command line) defaults, which is max_execution_time = 0 (unlimited). So, another way to avoid messing up drush timeouts would be to check just if PHP cli is being used for example with:

 $max_execution_time = ini_get('max_execution_time'); 
  if (php_sapi_name() == 'cli' && $max_execution_time > 0 && $max_execution_time < 240) {
    set_time_limit(240); 

IMO: this hardcoded 240-value should be settable in the admin UI, or at least via $conf in settings.php.

  • Dave Reid committed 195b668 on 8.x-1.x
    Issue #502744: Attempt to increase PHP time limit when...
Dave Reid’s picture

Issue summary: View changes
Status: Needs work » Closed (fixed)