From 8d01aeb4287be61195a43305e34f379086914f5d Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Wed, 17 Feb 2010 22:44:52 +0000 Subject: #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. --- modules/simpletest/tests/system_test.module | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'modules/simpletest/tests') 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)); +} + -- cgit v1.2.3