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
- Enable the page cache module and AJAX placeholder module
- Visit a page and verify the page can be served from the page cache.
- Render an element on a page using an
ajax_placeholderelement - 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
Issue fork ajax_placeholder-3528613
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
Comment #4
seanb