Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542

This commit is contained in:
Pantheon Automation 2015-08-27 12:03:05 -07:00 committed by Greg Anderson
parent 3b2511d96d
commit 81ccda77eb
2155 changed files with 54307 additions and 46870 deletions

View file

@ -29,18 +29,3 @@ function page_cache_help($route_name, RouteMatchInterface $route_match) {
return $output;
}
}
/**
* Implements hook_form_alter().
*/
function page_cache_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// If the page that's being built is cacheable, set the 'immutable' flag, to
// ensure that when the form is used, a new form build ID is generated when
// appropriate, to prevent information disclosure.
$request_policy = \Drupal::service('page_cache_request_policy');
$request = \Drupal::requestStack()->getCurrentRequest();
$request_is_cacheable = $request_policy->check($request) === RequestPolicyInterface::ALLOW;
if ($request_is_cacheable) {
$form_state->addBuildInfo('immutable', TRUE);
}
}

View file

@ -71,16 +71,19 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
$cache_contexts = [
'languages:' . LanguageInterface::TYPE_INTERFACE,
'route.menu_active_trails:account',
'route.menu_active_trails:footer',
'route.menu_active_trails:main',
'route.menu_active_trails:tools',
'route',
'theme',
'timezone',
'user.permissions',
// The user login block access depends on whether the current user is
// logged in or not.
'user.roles:anonymous',
// The cache contexts associated with the (in)accessible menu links are
// bubbled.
'user.roles:authenticated',
// The placed block is only visible on certain URLs through a visibility
// condition.
'url',
];
// Full node page 1.
@ -93,6 +96,9 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
'config:block.block.bartik_tools',
'config:block.block.bartik_login',
'config:block.block.bartik_footer',
'config:block.block.bartik_help',
'config:block.block.bartik_search',
'config:block.block.' . $block->id(),
'config:block.block.bartik_powered',
'config:block.block.bartik_main_menu',
'config:block.block.bartik_account_menu',
@ -123,6 +129,8 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
'config:block.block.bartik_content',
'config:block.block.bartik_tools',
'config:block.block.bartik_login',
'config:block.block.bartik_help',
'config:block.block.bartik_search',
'config:block.block.' . $block->id(),
'config:block.block.bartik_footer',
'config:block.block.bartik_powered',

View file

@ -67,6 +67,7 @@ class PageCacheTest extends WebTestBase {
$cache_entry = \Drupal::cache('render')->get($cid);
sort($cache_entry->tags);
$expected_tags = array(
'config:user.role.anonymous',
'pre_render',
'rendered',
'system_test_cache_tags_page',
@ -384,17 +385,25 @@ class PageCacheTest extends WebTestBase {
// Install the module that provides the test form.
$this->container->get('module_installer')
->install(['page_cache_form_test']);
// Uninstall the page_cache module to verify that form is immutable
// regardless of the internal page cache module.
$this->container->get('module_installer')->uninstall(['page_cache']);
\Drupal::service('router.builder')->rebuild();
$this->drupalGet('page_cache_form_test_immutability');
$this->assertText("Immutable: TRUE", "Form is immutable.");
// Uninstall the page_cache module, verify the flag is not set.
$this->container->get('module_installer')->uninstall(['page_cache']);
// The immutable flag is set unconditionally by system_form_alter(), set
// a flag to tell page_cache_form_test_module_implements_alter() to disable
// that implementation.
\Drupal::state()->set('page_cache_bypass_form_immutability', TRUE);
\Drupal::moduleHandler()->resetImplementations();
\Drupal::cache('render')->deleteAll();
$this->drupalGet('page_cache_form_test_immutability');
$this->assertText("Immutable: FALSE", "Form is not immutable,");
}
}

View file

@ -11,10 +11,30 @@ use Drupal\Core\Form\FormStateInterface;
* Implements hook_form_FORM_ID_alter().
*/
function page_cache_form_test_form_page_cache_form_test_alter(&$form, FormStateInterface $form_state, $form_id) {
// This runs earlier than system_form_alter() so we fore-go the immutability
// check to the process callback, by which time system_form_alter() has run.
$form['#process'][] = 'page_cache_form_test_form_page_cache_form_test_process';
}
/**
* Process callback to check immutability.
*/
function page_cache_form_test_form_page_cache_form_test_process($form, FormStateInterface $form_state) {
if (isset($form_state->getBuildInfo()['immutable']) && $form_state->getBuildInfo()['immutable']) {
$form['#suffix'] = 'Immutable: TRUE';
}
else {
$form['#suffix'] = 'Immutable: FALSE';
}
return $form;
}
/**
* Implements hook_module_implements_alter().
*/
function page_cache_form_test_module_implements_alter(&$implementations, $hook) {
if ($hook === 'form_alter' && \Drupal::state()->get('page_cache_bypass_form_immutability', FALSE)) {
// Disable system_form_alter
unset($implementations['system']);
}
}