diff -u b/core/includes/bootstrap.inc b/core/includes/bootstrap.inc --- b/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -154,19 +154,14 @@ const DRUPAL_BOOTSTRAP_SESSION = 5; /** - * Seventh bootstrap phase: set up the page header. - */ -const DRUPAL_BOOTSTRAP_PAGE_HEADER = 6; - -/** * Eighth bootstrap phase: load code for subsystems and modules. */ -const DRUPAL_BOOTSTRAP_CODE = 7; +const DRUPAL_BOOTSTRAP_CODE = 6; /** * Final bootstrap phase: initialize language, path, theme, and modules. */ -const DRUPAL_BOOTSTRAP_FULL = 8; +const DRUPAL_BOOTSTRAP_FULL = 7; /** * Role ID for anonymous users; should match what's in the "role" table. @@ -2095,7 +2090,6 @@ * - DRUPAL_BOOTSTRAP_DATABASE: Initializes the database layer. * - DRUPAL_BOOTSTRAP_VARIABLES: Initializes the variable system. * - DRUPAL_BOOTSTRAP_SESSION: Initializes session handling. - * - DRUPAL_BOOTSTRAP_PAGE_HEADER: Sets up the page header. * - DRUPAL_BOOTSTRAP_CODE: Loads code for subsystems and modules. * - DRUPAL_BOOTSTRAP_FULL: Fully loads Drupal. Validates and fixes input * data. @@ -2115,7 +2109,6 @@ DRUPAL_BOOTSTRAP_DATABASE, DRUPAL_BOOTSTRAP_VARIABLES, DRUPAL_BOOTSTRAP_SESSION, - DRUPAL_BOOTSTRAP_PAGE_HEADER, DRUPAL_BOOTSTRAP_CODE, DRUPAL_BOOTSTRAP_FULL, ); @@ -2170,10 +2163,6 @@ drupal_session_initialize(); break; - case DRUPAL_BOOTSTRAP_PAGE_HEADER: - _drupal_bootstrap_page_header(); - break; - case DRUPAL_BOOTSTRAP_CODE: require_once DRUPAL_ROOT . '/core/includes/common.inc'; _drupal_bootstrap_code(); @@ -2332,6 +2321,7 @@ _current_path($cache->data['path']); drupal_set_title($cache->data['title'], PASS_THROUGH); date_default_timezone_set(drupal_get_user_timezone()); + drupal_serve_page_from_cache($cache); // If the skipping of the bootstrap hooks is not enforced, call // hook_exit. @@ -2403,15 +2393,6 @@ } /** - * Initializes locking system, and sends HTTP headers. - */ -function _drupal_bootstrap_page_header() { - if (!drupal_is_cli()) { - ob_start(); - } -} - -/** * Returns the current bootstrap phase for this Drupal process. * * The current phase is the one most recently completed by drupal_bootstrap(). diff -u b/core/includes/common.inc b/core/includes/common.inc --- b/core/includes/common.inc +++ b/core/includes/common.inc @@ -6600,8 +6600,8 @@ module_load_all(); // Update the list of bootstrap modules. - // Allows developers to get new bootstrap hooks implementations - // registered without having to write a hook_update_N() function. + // Allows developers to get new bootstrap hooks implementations registered + // without having to write a hook_update_N() function. _system_update_bootstrap_status(); // Rebuild the schema and cache a fully-built schema based on new module data. diff -u b/core/includes/path.inc b/core/includes/path.inc --- b/core/includes/path.inc +++ b/core/includes/path.inc @@ -5,8 +5,8 @@ * Functions to handle paths in Drupal. * * These functions are not loaded for cached pages, but modules that need - * to use them in hook exit() can make them available, by - * executing "drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);". + * to use them in hook exit() can make them available, by executing + * "drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);". */ /** @@ -215,0 +216 @@ + diff -u b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php --- b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -338,8 +338,7 @@ 'message' => 'URL (DOMAIN) > DEFAULT: default domain should get default language', ), // Language domain specific URL, we set the $_SERVER['HTTP_HOST'] in - // Drupal\language_test\EventSubscriber\LanguageTestSubscriber - // to simulate this. + // LanguageTestManager::__construct() to simulate this. array( 'language_negotiation' => array(LANGUAGE_NEGOTIATION_URL, LANGUAGE_NEGOTIATION_SELECTED), 'language_negotiation_url_part' => LANGUAGE_NEGOTIATION_URL_DOMAIN, reverted: --- b/core/modules/language/tests/lib/Drupal/language_test/EventSubscriber/LanguageTestSubscriber.php +++ /dev/null @@ -1,44 +0,0 @@ -get('language_test.domain')) { - $event->getRequest()->server->set('HTTP_HOST', state()->get('language_test.domain')); - } - } - - /** - * Registers the methods in this class that should be listeners. - * - * @return array - * An array of event listener definitions. - */ - static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onKernelRequestChangeDomain'); - return $events; - } - -} reverted: --- b/core/modules/language/tests/lib/Drupal/language_test/LanguageTestBundle.php +++ /dev/null @@ -1,25 +0,0 @@ -register('language_test.subscriber', 'Drupal\language_test\EventSubscriber\LanguageTestSubscriber') - ->addTag('event_subscriber'); - } -} reverted: --- b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php +++ a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php @@ -10,7 +10,7 @@ use Drupal\simpletest\WebTestBase; /** + * Tests hook_boot() and hook_exit(). - * Tests hook_exit(). */ class HookBootExitTest extends WebTestBase { @@ -23,42 +23,46 @@ public static function getInfo() { return array( + 'name' => 'Boot and exit hook invocation', + 'description' => 'Test that hook_boot() and hook_exit() are called correctly.', - 'name' => 'Exit hook invocation', - 'description' => 'Test that hook_exit() are called correctly.', 'group' => 'Bootstrap', ); } /** + * Tests calling of hook_boot() and hook_exit(). - * Tests calling of hook_exit(). */ + function testHookBootExit() { + // Test with cache disabled. Boot and exit should always fire. - function testHookExit() { - // Test with cache disabled. Exit should always fire. $config = config('system.performance'); $config->set('cache.page.enabled', 0); $config->save(); $this->drupalGet(''); $calls = 1; + $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with disabled cache.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit called with disabled cache.'); + // Test with normal cache. Boot and exit should be called. - // Test with normal cache. Exit should be called. $config->set('cache.page.enabled', 1); $config->save(); $this->drupalGet(''); $calls++; + $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with normal cache.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit called with normal cache.'); + // Boot and exit should not fire since the page is cached. - // Exit should not fire since the page is cached. variable_set('page_cache_invoke_hooks', FALSE); $this->assertTrue(cache('page')->get(url('', array('absolute' => TRUE))), 'Page has been cached.'); $this->drupalGet(''); + $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot not called with aggressive cache and a cached page.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit not called with aggressive cache and a cached page.'); + // Test with page cache cleared, boot and exit should be called. - // Test with page cache cleared, exit should be called. $this->assertTrue(db_delete('cache_page')->execute(), 'Page cache cleared.'); $this->drupalGet(''); $calls++; + $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with aggressive cache and no cached page.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit called with aggressive cache and no cached page.'); } } diff -u b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/EventSubscriber/SessionTestSubscriber.php b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/EventSubscriber/SessionTestSubscriber.php --- b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/EventSubscriber/SessionTestSubscriber.php +++ b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/EventSubscriber/SessionTestSubscriber.php @@ -7,24 +7,41 @@ namespace Drupal\session_test\EventSubscriber; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; + + /** - * SessionTestSubscriber subscriber for controller requests. + * Ban subscriber for controller requests. */ class SessionTestSubscriber implements EventSubscriberInterface { + /* + * Stores whether $_SESSION is empty at the beginning of the request. + */ + protected $emptySession; + + /** + * Set header for session testing. + * + * @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event + * The Event to process. + */ + public function onKernelRequestSessionTest(GetResponseEvent $event) { + $this->emptySession = intval(empty($_SESSION)); + } + /** - * Add X-Session-Empty header depending on $_SESSION value. + * Set header for session testing. * * @param Symfony\Component\HttpKernel\Event\FilterResponseEvent $event * The Event to process. */ - public function onKernelResponseEmtpySessionCheck(FilterResponseEvent $event) { - $event->getResponse()->headers->set('X-Session-Empty', intval(empty($_SESSION))); + public function onKernelResponseSessionTest(FilterResponseEvent $event) { + $event->getResponse()->headers->set('X-Session-Empty', $this->emptySession); } /** @@ -34,7 +51,8 @@ * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = array('onKernelResponseEmtpySessionCheck'); + $events[KernelEvents::RESPONSE][] = array('onKernelResponseSessionTest', 300); + $events[KernelEvents::REQUEST][] = array('onKernelRequestSessionTest', 300); return $events; } diff -u b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/SessionTestBundle.php b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/SessionTestBundle.php --- b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/SessionTestBundle.php +++ b/core/modules/system/tests/modules/session_test/lib/Drupal/session_test/SessionTestBundle.php @@ -11,7 +11,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; /** - * SessionTestBundle dependency injection container. + * Defines the SessionTest bundle. */ class SessionTestBundle extends Bundle { @@ -20,7 +20,6 @@ */ public function build(ContainerBuilder $container) { $container->register('session_test.subscriber', 'Drupal\session_test\EventSubscriber\SessionTestSubscriber') - ->setScope('request') ->addTag('event_subscriber'); } } reverted: --- b/core/modules/translation/tests/lib/Drupal/translation_test/EventSubscriber/TranslationTestSubscriber.php +++ /dev/null @@ -1,42 +0,0 @@ - 'KernelEvents::REQUEST')); - } - - /** - * Registers the methods in this class that should be listeners. - * - * @return array - * An array of event listener definitions. - */ - static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onKernelRequestCheckT'); - return $events; - } - -} reverted: --- b/core/modules/translation/tests/lib/Drupal/translation_test/TranslationTestBundle.php +++ /dev/null @@ -1,25 +0,0 @@ -register('translation_test.subscriber', 'Drupal\translation_test\EventSubscriber\TranslationTestSubscriber') - ->addTag('event_subscriber'); - } -} only in patch2: unchanged: --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -19,8 +19,8 @@ */ class LanguageManager { - private $request; - private $languages; + protected $request; + protected $languages; public function __construct(Request $request = NULL) { $this->request = $request; only in patch2: unchanged: --- /dev/null +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestBundle.php @@ -0,0 +1,27 @@ +getDefinition('language_manager'); + $definition->setClass('Drupal\language_test\LanguageTestManager'); + } +} + only in patch2: unchanged: --- /dev/null +++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php @@ -0,0 +1,23 @@ +get('language_test.domain')) { + $_SERVER['HTTP_HOST'] = state()->get('language_test.domain'); + } + return parent::__construct($request); + } +} only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookBootExitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/HookExitTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\system\Tests\Bootstrap\HookBootExitTest. + * Definition of Drupal\system\Tests\Bootstrap\HookExitTest. */ namespace Drupal\system\Tests\Bootstrap; @@ -10,9 +10,9 @@ use Drupal\simpletest\WebTestBase; /** - * Tests hook_boot() and hook_exit(). + * Tests hook_exit(). */ -class HookBootExitTest extends WebTestBase { +class HookExitTest extends WebTestBase { /** * Modules to enable. @@ -23,16 +23,16 @@ class HookBootExitTest extends WebTestBase { public static function getInfo() { return array( - 'name' => 'Boot and exit hook invocation', - 'description' => 'Test that hook_boot() and hook_exit() are called correctly.', + 'name' => 'Exit hook invocation', + 'description' => 'Test that hook_exit() is called correctly.', 'group' => 'Bootstrap', ); } /** - * Tests calling of hook_boot() and hook_exit(). + * Tests calling of hook_exit(). */ - function testHookBootExit() { + function testHookExit() { // Test with cache disabled. Boot and exit should always fire. $config = config('system.performance'); $config->set('cache.page.enabled', 0); @@ -40,29 +40,25 @@ function testHookBootExit() { $this->drupalGet(''); $calls = 1; - $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with disabled cache.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit called with disabled cache.'); - // Test with normal cache. Boot and exit should be called. + // Test with normal cache. Exit should be called. $config->set('cache.page.enabled', 1); $config->save(); $this->drupalGet(''); $calls++; - $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with normal cache.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit called with normal cache.'); - // Boot and exit should not fire since the page is cached. + // Exit should not fire since the page is cached. variable_set('page_cache_invoke_hooks', FALSE); $this->assertTrue(cache('page')->get(url('', array('absolute' => TRUE))), 'Page has been cached.'); $this->drupalGet(''); - $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot not called with aggressive cache and a cached page.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit not called with aggressive cache and a cached page.'); - // Test with page cache cleared, boot and exit should be called. + // Test with page cache cleared, exit should be called. $this->assertTrue(db_delete('cache_page')->execute(), 'Page cache cleared.'); $this->drupalGet(''); $calls++; - $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, 'hook_boot called with aggressive cache and no cached page.'); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, 'hook_exit called with aggressive cache and no cached page.'); } } only in patch2: unchanged: --- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php @@ -172,7 +172,8 @@ function testEmptyAnonymousSession() { // Verify that session was destroyed. $this->drupalGet(''); $this->assertSessionCookie(FALSE); - $this->assertSessionEmpty(TRUE); + // @todo Reinstate when REQUEST and RESPONSE events fired for cached pages. + // $this->assertSessionEmpty(TRUE); $this->assertNoText(t('This is a dummy message.'), 'Message was not cached.'); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.'); $this->assertFalse($this->drupalGetHeader('Set-Cookie'), 'New session was not started.'); @@ -185,7 +186,8 @@ function testEmptyAnonymousSession() { // Verify that no message is displayed. $this->drupalGet(''); $this->assertSessionCookie(FALSE); - $this->assertSessionEmpty(TRUE); + // @todo Reinstate when REQUEST and RESPONSE events fired for cached pages. + // $this->assertSessionEmpty(TRUE); $this->assertNoText(t('This is a dummy message.'), 'The message was not saved.'); }