summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-17 22:44:52 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-02-17 22:44:52 +0000
commit8d01aeb4287be61195a43305e34f379086914f5d (patch)
tree88ef91e8532ed82085dfa5ce8a854116f891173b /modules
parent8847f4c9a2edcd2f555d6a47b5037c88c671cc3c (diff)
downloadbrdo-8d01aeb4287be61195a43305e34f379086914f5d.tar.gz
brdo-8d01aeb4287be61195a43305e34f379086914f5d.tar.bz2
#710142 by Berdir, moshe weitzman, chx: Handle exceptions in shutdown functions (with tests). Hopefully the last of these weird 'Stack frame in Unknown line 0' errors.
Diffstat (limited to 'modules')
-rw-r--r--modules/search/search.module2
-rw-r--r--modules/simpletest/tests/system_test.module33
-rw-r--r--modules/system/system.api.php2
-rw-r--r--modules/system/system.test28
4 files changed, 63 insertions, 2 deletions
diff --git a/modules/search/search.module b/modules/search/search.module
index 4fefecc60..36a0c1820 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -341,7 +341,7 @@ function search_dirty($word = NULL) {
function search_cron() {
// We register a shutdown function to ensure that search_total is always up
// to date.
- register_shutdown_function('search_update_totals');
+ drupal_register_shutdown_function('search_update_totals');
foreach(variable_get('search_active_modules', array('node', 'user')) as $module) {
// Update word index
diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module
index b37019f8c..a638b70f5 100644
--- a/modules/simpletest/tests/system_test.module
+++ b/modules/simpletest/tests/system_test.module
@@ -94,6 +94,13 @@ function system_test_menu() {
'type' => MENU_CALLBACK,
);
+ $items['system-test/shutdown-functions'] = array(
+ 'title' => 'Test main content duplication',
+ 'page callback' => 'system_test_page_shutdown_functions',
+ 'access callback' => TRUE,
+ 'type' => MENU_CALLBACK,
+ );
+
return $items;
}
@@ -280,3 +287,29 @@ function system_test_main_content_fallback() {
return t('Content to test main content fallback');
}
+/**
+ * A simple page callback which adds a register shutdown function.
+ */
+function system_test_page_shutdown_functions($arg1, $arg2) {
+ drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2);
+}
+
+/**
+ * Dummy shutdown function which registers another shutdown function.
+ */
+function _system_test_first_shutdown_function($arg1, $arg2) {
+ // Output something, page has already been printed and the session stored
+ // so we can't use drupal_set_message.
+ print t('First shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2));
+ drupal_register_shutdown_function('_system_test_second_shutdown_function', $arg1, $arg2);
+}
+
+/**
+ * Dummy shutdown function.
+ */
+function _system_test_second_shutdown_function($arg1, $arg2) {
+ // Output something, page has already been printed and the session stored
+ // so we can't use drupal_set_message.
+ print t('Second shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2));
+}
+
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 5162b69c7..153ddca83 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -877,7 +877,7 @@ function hook_forms($form_id, $args) {
function hook_boot() {
// we need user_access() in the shutdown function. make sure it gets loaded
drupal_load('module', 'user');
- register_shutdown_function('devel_shutdown');
+ drupal_register_shutdown_function('devel_shutdown');
}
/**
diff --git a/modules/system/system.test b/modules/system/system.test
index e33ad11a8..79e141225 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -1598,3 +1598,31 @@ class FloodFunctionalTest extends DrupalWebTestCase {
$this->assertFalse(flood_is_allowed($name, $threshold));
}
}
+
+/**
+ * Functional tests shutdown functions.
+ */
+class ShutdownFunctionsTest extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Shutdown functions',
+ 'description' => 'Functional tests for shutdown functions',
+ 'group' => 'System',
+ );
+ }
+
+ function setUp() {
+ parent::setUp('system_test');
+ }
+
+ /**
+ * Test flood control mechanism clean-up.
+ */
+ function testShutdownFunctions() {
+ $arg1 = $this->randomName();
+ $arg2 = $this->randomName();
+ $this->drupalGet('system-test/shutdown-functions/' . $arg1 . '/' . $arg2);
+ $this->assertText(t('First shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2)));
+ $this->assertText(t('Second shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2)));
+ }
+} \ No newline at end of file