--- modules/node/node.module.1.947.2.2.	Tue Feb 26 14:04:00 2008
+++ modules/node/node.module	Tue Feb 26 15:13:22 2008
@@ -2288,8 +2288,9 @@ function node_access_rebuild($batch_mode
       batch_set($batch);
     }
     else {
-      // If not in 'safe mode', increase the maximum execution time.
-      if (!ini_get('safe_mode')) {
+      // If not in 'safe mode' and certain the maximum execution time is less
+      // than 240 seconds then increase it.
+      if ((!ini_get('safe_mode')) && is_numeric($time_limit = ini_get('max_execution_time')) && $time_limit < 240) {
         set_time_limit(240);
       }
       $result = db_query("SELECT nid FROM {node}");
