Problem/Motivation
After #2372389: Expose session handler in container, disabling and enabling of session saving has moved to WriteSafeSessionHandlerInterface::setSessionWritable()
while SessionManager::isEnabled()
, ::enable()
and ::disable()
have been deprecated. This issue removes the usages of SessionManager::isEnabled()
, ::enable()
and ::disable()
in core.
Proposed resolution
Replace in the following files. @znerol in #2372389-28: Expose session handler in container
Calls to those methods should be replaced by the respective methods of the write-safe handler. A quick grep through the source tree turned up the following files which need to be updated:
core/lib/Drupal/Core/Session/AccountSwitcher.php
core/modules/system/src/Tests/Datetime/DrupalDateTimeTest.php
core/modules/system/src/Tests/Session/AccountSwitcherTest.php
core/modules/system/src/Tests/Session/SessionTest.php
core/modules/system/tests/modules/session_test/src/Controller/SessionTestController.php
core/modules/user/src/Tests/Views/ArgumentDefaultTest.php
Remaining tasks
Patch
Reviews
Commit
User interface changes
None
API changes
SessionManager::enable()
and SessionManager::disable()
will be removed. WriteSafeSessionHandlerInterface::setSessionWritable()
is the new proper way of doing session write enabling/disabling.
Beta phase evaluation
Issue category | Task |
---|---|
Prioritized changes | The main goal of this issue is switching away from previously deprecated code. |
Disruption | Moderately disruptive for contributed and custom modules because it will require a minor internal refactoring |
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff.txt | 4.53 KB | almaudoh |
#21 | 2426031-remove-deprecated-enable-disable-21.patch | 10.74 KB | almaudoh |
#15 | interdiff.txt | 3.6 KB | almaudoh |
#15 | 2426031-remove-deprecated-enable-disable-15.patch | 10.48 KB | almaudoh |
#9 | 2426031-remove-deprecated-enable-disable-9.patch | 11.79 KB | cpj |
Comments
Comment #1
almaudoh CreditAttribution: almaudoh commentedPostponed until #2372389: Expose session handler in container is in.
Comment #2
almaudoh CreditAttribution: almaudoh commented#2372389: Expose session handler in container is in so we can unpostpone this issue.
Comment #3
cpj CreditAttribution: cpj commentedComment #4
cpj CreditAttribution: cpj commentedComment #5
cpj CreditAttribution: cpj commentedComment #6
cpj CreditAttribution: cpj commentedComment #7
cpj CreditAttribution: cpj commentedComment #9
cpj CreditAttribution: cpj commentedComment #10
cpj CreditAttribution: cpj commentedComment #12
cpj CreditAttribution: cpj commented@almaudoh - I've made the changes & submitted a patch. I don't understand the errors. Can you help ? Thanks
Comment #13
almaudoh CreditAttribution: almaudoh commentedSome small nitpicks.
s/WriteCheckSessionHandlerInterface/WriteSafeSessionHandlerInterface/
Out of scope
Checking the test fails now.
Comment #14
almaudoh CreditAttribution: almaudoh commentedThanks @cpj for the patch. These are possibly the causes of the test fails, in addition to the phpunit file move mentioned in #13
WriteSafeSessionHandlerInterface::setSessionWritable() is not chainable. (I'm wondering maybe we should make it chainable in this issue).
Comment #15
almaudoh CreditAttribution: almaudoh commentedAttached patch for #13 and #14
Comment #16
cpj CreditAttribution: cpj commentedThanks @almaudoh - not sure where that phpunit stuff came from... It would be more like a drop-in replacement if it was chainable but I personally don't think its a "must-have". Or is there a "Best Practice" that says it should be chainable ?
#15 works in my system, but I guess we need someone else to do the RTBC ?
Comment #17
znerol CreditAttribution: znerol commentedComment should be updated too. Apart from that the patch is ready.
Comment #18
znerol CreditAttribution: znerol commentedNot sure whether we need a change record here. This functionality of the session manager has not been mentioned in the CR discussing the session manager. The one for the account switcher suggest that direct calls to
drupal_save_session
are not necessary anymore.Comment #19
neclimdulI hate to be a stickler but the title and summary mention code being deprecated. I couldn't find documentation of this and the interface doesn't document it either. I agree with the issue but we should clarify the state of that code somewhere. A quick @deprecated with when it will be removed on SessionManagerInterface would address this for me.
Comment #20
almaudoh CreditAttribution: almaudoh commented@neclimdul, those methods were deprecated by #2372389: Expose session handler in container.
There's nothing like a change notice if that's what you mean. But it's documented on the interface.
Do we need a change notice for this?
Comment #21
almaudoh CreditAttribution: almaudoh commentedUpdates docs nits, renames $sessionHandler to $writeSafeHandler and changes
ArgumentDefaultTest
to useaccount_switcher
service instead.DrupalDateTimeTest
also needs to be updated to useaccount_switcher
service, but that bit of code is also being modified in a different way by #2328645: Remove remaining global $user.Comment #22
neclimdulSorry, I don't even know what I was looking at you are correct. Please ignore #19
Comment #23
neclimdulLooked over this a couple more times and can't really see any problems. Looks good!
Comment #24
alexpottCommitted 7e41973 and pushed to 8.0.x. Thanks!
This is part of the on-going work on sessions - see #2372389: Expose session handler in container
Thanks for adding the beta evaluation to the issue summary.
Comment #26
neclimdulis there a follow up to follow for actually removing the methods from the interface?
Comment #27
almaudoh CreditAttribution: almaudoh commentedCreated #2429103: Remove deprecated methods SessionManager::enable(), SessionManager::disable() and SessionManager::isEnabled()