Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.909
diff -u -r1.909 common.inc
--- includes/common.inc	22 May 2009 03:19:42 -0000	1.909
+++ includes/common.inc	22 May 2009 14:21:11 -0000
@@ -1911,6 +1911,24 @@
 }
 
 /**
+ * Attempt to set the PHP maximum execution time.
+ *
+ * A wrapper around the PHP function set_time_limit(). Before calling it, 
+ * we check if this function is not disabled for security reasons and if
+ * the PHP safe mode is not enabled otherwise in both cases it could raise
+ * PHP warning messages.
+ *
+ * @param $time_limit
+ *   An integer specifying the new time limit, in seconds. A value of 0
+ *   indicates unlimited execution time.
+ */
+function drupal_set_time_limit($time_limit) {
+  if (function_exists('set_time_limit') && !ini_get('safe_mode')) {
+    set_time_limit($time_limit);
+  }
+}
+
+/**
  * Returns the path to a system item (module, theme, etc.).
  *
  * @param $type
@@ -3033,10 +3051,8 @@
   // Allow execution to continue even if the request gets canceled.
   @ignore_user_abort(TRUE);
 
-  // Try to increase the maximum execution time if it is too low.
-  if (ini_get('max_execution_time') < 240) {
-    @set_time_limit(240);
-  }
+  // Try to reset the execution time and set a sufficient new time limit.
+  drupal_set_time_limit(240);
 
   // Fetch the cron semaphore
   $semaphore = variable_get('cron_semaphore', FALSE);
Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.215
diff -u -r1.215 locale.inc
--- includes/locale.inc	12 May 2009 08:37:44 -0000	1.215
+++ includes/locale.inc	22 May 2009 12:14:09 -0000
@@ -1165,10 +1165,8 @@
  *   Text group to import PO file into (eg. 'default' for interface translations)
  */
 function _locale_import_po($file, $langcode, $mode, $group = NULL) {
-  // If not in 'safe mode', increase the maximum execution time.
-  if (!ini_get('safe_mode')) {
-    set_time_limit(240);
-  }
+  // Try to reset the execution time and set a sufficient new time limit.
+  drupal_set_time_limit(240);
 
   // Check if we have the language already in the database.
   if (!db_query("SELECT COUNT(language) FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchField()) {
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1054
diff -u -r1.1054 node.module
--- modules/node/node.module	22 May 2009 11:34:05 -0000	1.1054
+++ modules/node/node.module	22 May 2009 12:14:10 -0000
@@ -2770,10 +2770,9 @@
       batch_set($batch);
     }
     else {
-      // If not in 'safe mode', increase the maximum execution time.
-      if (!ini_get('safe_mode')) {
-        set_time_limit(240);
-      }
+      // Try to reset the execution time and set a sufficient new time limit.
+      drupal_set_time_limit(240);
+
       $nids = db_query("SELECT nid FROM {node}")->fetchCol();
       foreach ($nids as $nid) {
         $node = node_load($nid, NULL, TRUE);
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.104
diff -u -r1.104 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	20 May 2009 22:16:38 -0000	1.104
+++ modules/simpletest/drupal_web_test_case.php	22 May 2009 12:14:10 -0000
@@ -917,7 +917,7 @@
     // Create the files directory.
     file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
 
-    set_time_limit($this->timeLimit);
+    drupal_set_time_limit($this->timeLimit);
   }
 
   /**
Index: scripts/run-tests.sh
===================================================================
RCS file: /cvs/drupal/drupal/scripts/run-tests.sh,v
retrieving revision 1.26
diff -u -r1.26 run-tests.sh
--- scripts/run-tests.sh	13 Apr 2009 12:23:26 -0000	1.26
+++ scripts/run-tests.sh	22 May 2009 12:14:10 -0000
@@ -63,10 +63,8 @@
 
 $test_list = simpletest_script_get_test_list();
 
-// If not in 'safe mode', increase the maximum execution time.
-if (!ini_get('safe_mode')) {
-  set_time_limit(0);
-}
+// Try to reset the execution time and set it to unlimited.
+drupal_set_time_limit(0);
 
 simpletest_script_reporter_init();
 

