Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.911
diff -u -r1.911 common.inc
--- includes/common.inc	24 May 2009 17:39:30 -0000	1.911
+++ includes/common.inc	25 May 2009 22:21:56 -0000
@@ -2202,6 +2202,23 @@
 }
 
 /**
+ * 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 available; it could be disabled by the server
+ * administrator. We also hide all the errors that could occur when calling it.
+ *
+ * @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')) {
+    @set_time_limit($time_limit);
+  }
+}
+
+/**
  * Returns the path to a system item (module, theme, etc.).
  *
  * @param $type
@@ -3324,10 +3341,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.217
diff -u -r1.217 locale.inc
--- includes/locale.inc	25 May 2009 18:22:30 -0000	1.217
+++ includes/locale.inc	25 May 2009 21:41:05 -0000
@@ -1164,10 +1164,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.1056
diff -u -r1.1056 node.module
--- modules/node/node.module	25 May 2009 15:39:12 -0000	1.1056
+++ modules/node/node.module	25 May 2009 21:41:05 -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.107
diff -u -r1.107 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	25 May 2009 05:20:16 -0000	1.107
+++ modules/simpletest/drupal_web_test_case.php	25 May 2009 21:41:06 -0000
@@ -1000,7 +1000,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	25 May 2009 21:41:06 -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();
 

