From af08328e8efff8ae7c5d39cfbdde15a7954525c1 Mon Sep 17 00:00:00 2001 From: Simon Gow Date: Mon, 14 Jan 2019 14:35:58 +1300 Subject: [PATCH 1/3] Existing sessions need to set a new cookie on each request, if the session exists, otherwise our expiry is never updated and sessions can't roll on every request. --- src/Control/Session.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Control/Session.php b/src/Control/Session.php index e2591d2c5..1b226c021 100644 --- a/src/Control/Session.php +++ b/src/Control/Session.php @@ -324,6 +324,12 @@ class Session } session_start(); + + // Session start emits a cookie, but only if there's no existing session. If there is a session tied to + // this request, make sure the session is held for the entire timeout by refreshing the cookie age. + if ($this->requestContainsSessionId($request)) { + Cookie::set(session_name(), session_id(), $timeout / 86400, $path, $domain ?: null, $secure, true); + } } else { // If headers are sent then we can't have a session_cache_limiter otherwise we'll get a warning session_cache_limiter(null); From c28670ebedd8d8ebe83421209790c50b3b1dd673 Mon Sep 17 00:00:00 2001 From: Simon Gow Date: Fri, 18 Jan 2019 10:07:53 +1300 Subject: [PATCH 2/3] #8724 - Session timeout regression Only emit the session refresh cookie if the session timeout is set. --- src/Control/Session.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Control/Session.php b/src/Control/Session.php index 1b226c021..f0ad80545 100644 --- a/src/Control/Session.php +++ b/src/Control/Session.php @@ -325,9 +325,9 @@ class Session session_start(); - // Session start emits a cookie, but only if there's no existing session. If there is a session tied to - // this request, make sure the session is held for the entire timeout by refreshing the cookie age. - if ($this->requestContainsSessionId($request)) { + // Session start emits a cookie, but only if there's no existing session. If there is a session timeout + // tied to this request, make sure the session is held for the entire timeout by refreshing the cookie age. + if ($timeout && $this->requestContainsSessionId($request)) { Cookie::set(session_name(), session_id(), $timeout / 86400, $path, $domain ?: null, $secure, true); } } else { From e087e564e13d7c30b62850a271131684a619789e Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 24 Jan 2019 16:45:38 +0200 Subject: [PATCH 3/3] Fix tests not loading fixtures and loading themes in CWP recipe kitchen sink --- tests/php/Forms/TreeMultiselectFieldTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/php/Forms/TreeMultiselectFieldTest.php b/tests/php/Forms/TreeMultiselectFieldTest.php index 5b2f14a65..e2cc56741 100644 --- a/tests/php/Forms/TreeMultiselectFieldTest.php +++ b/tests/php/Forms/TreeMultiselectFieldTest.php @@ -7,11 +7,17 @@ use SilverStripe\Dev\SapphireTest; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormTemplateHelper; use SilverStripe\Forms\TreeMultiselectField; +use SilverStripe\ORM\Tests\HierarchyTest\TestObject; +use SilverStripe\View\SSViewer; class TreeMultiselectFieldTest extends SapphireTest { protected static $fixture_file = 'TreeDropdownFieldTest.yml'; + protected static $extra_dataobjects = [ + TestObject::class, + ]; + protected $formId = 'TheFormID'; protected $fieldName = 'TestTree'; @@ -54,6 +60,9 @@ class TreeMultiselectFieldTest extends SapphireTest { parent::setUp(); + // Don't let other themes interfere with these tests + SSViewer::set_themes([]); + $this->form = $this->buildFormMock(); $this->field = $this->buildField($this->form); $this->folders = $this->loadFolders();