Closed simonoche closed 3 years ago
I can confirm this issue only appears for editors. Basic users (ROLE_USER) are not affected by this behavious.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Environment
Sonata packages
Symfony packages
PHP version
PHP 7.4.7 (cli) (built: Jun 12 2020 00:04:10) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.7, Copyright (c), by Zend Technologies
Subject
First load of any page, with a valid "remember me" cookie set AND when the session cookie has expired (or been removed) end to an Exception.
Steps to reproduce
Use "Remember Me" Symfony feature. I guess the user must be an editor / admin in this particular case. Then login with "remember me" checked (or automatically set with always_remember_me in my case). You'll get 2 cookies : 1 for the session, 1 for the "remember me". Then delete the session cookie, and refresh any public page (CMS).
Expected results
Should serve the proper Page (or Snapshot)
Actual results
You get this exception for the first load : Sonata\PageBundle\Exception\InternalErrorException "No page instance available for the url, run the sonata:page:update-core-routes and sonata:page:create-snapshots commands"
Ideas
At first, as the system does not recognize any user, Sonata\PageBundle\CmsManager\CmsSnapshotManager is used. The page, at this point, is matched.
Then, for any reason, the target Manager becomes Sonata\PageBundle\CmsManager\CmsPageManager, where no page has been matched. Probably because nothing calls setCurrentPage.
In Sonata\PageBundle\Listener\ResponseListener::onCoreResponse
$cms = $this->cmsSelector->retrieve();
The served Manager in this particular case is CmsPageManager, which seems coherent, because at the end, there is an admin logged-in.
The CmsSnapshotManager is "filled" with the proper page, but not the CmsPageManager.