Problem/Motivation

The AJAX placeholder module uses the shared tempstore to store the callbacks for things it wants to render. When using AJAX placeholders for anonymous users, the shared tempstore creates a session in \Drupal\Core\TempStore\SharedTempStoreFactory::get():

    // Use the currently authenticated user ID or the active user ID unless
    // the owner is overridden.
    if (!isset($owner)) {
      $owner = $this->currentUser->id();
      if ($this->currentUser->isAnonymous()) {
        $owner = $this->requestStack->getSession()->get('core.tempstore.shared.owner', Crypt::randomBytesBase64());
      }
    }

The created session then breaks the Drupal page cache, since Drupal\Core\PageCache\RequestPolicy\NoSessionOpen automatically denies the page cache for all users that have a session.

Steps to reproduce

  1. Enable the page cache module and AJAX placeholder module
  2. Visit a page and verify the page can be served from the page cache.
  3. Render an element on a page using an ajax_placeholder element
  4. The page that was previously served from the cache, is now no longer cached.

Proposed resolution

Since the session is only created when no owner is passed to \Drupal\Core\TempStore\SharedTempStoreFactory::get(), we should pass an owner ID.

Remaining tasks

Write a patch
Commit

User interface changes

None

API changes

None

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

seanb created an issue. See original summary.

  • seanb committed 88e486f1 on 1.0.x
    Issue #3528613: AJAX placeholders starts a session and breaks page...
seanb’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.