Skip to content

readingMode session value not persisting #962

Closed
sheadawson opened this Issue Mar 3, 2014 · 3 comments

4 participants

@sheadawson

In SS 3.1, visiting a page in the frontend with ?stage=Stage appended to the URL (or in CMS preview) allows the site to be viewed in draft mode. I can see that the session value "readingMode" gets stored (Versioned::choose_site_stage()) so that subsequent page requests are also displayed in draft mode. But this session value seems to be getting dropped during the subsequent request, so navigating to a draft page displayed in the navigation results in a 404.

I have tested in 3.0 and the session value persists as expected. It's quite an issue for cms users using the draft preview window, as they are unable to navigate around the draft site despite the big green button saying they are viewing in draft mode.

From what I've been able to learn so far, readingMode gets dropped after the call to pushCurrent here in ModelAsController.php:

    public function handleRequest(SS_HTTPRequest $request, DataModel $model) {
        $this->request = $request;
        $this->setDataModel($model);

        $this->pushCurrent();
@tractorcow

This is because VersionedRequestFilter calls Versioned::choose_site_stage(); before a controller has been initialised; Meaning that this is stored in the Session::$default_session session.

VersionedRequestFilter::preRequest is actually PASSED the current session, but because it's oblivious to this, it instead attempts to use the Session static methods, which of course can't find the current controller's session (becuase there is no controller yet).

PR incoming with a fix.

@tractorcow tractorcow referenced this issue in silverstripe/silverstripe-framework Mar 4, 2014
Merged

BUG Fix Versioned stage not persisting in Session #2918

@simonwelsh simonwelsh added the 3.1 label Mar 16, 2014
@hafriedlander
SilverStripe Ltd. member

And merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.