Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up for #2448699-15: Implement caching for the masquerade block and links with a 'masquerade' cache context
Masquerade is using $_SESSION['masquerading'] everywhere, except in the MasqueradeCacheContext::getContext(), where it uses \Symfony\Component\HttpFoundation\Session\Session::has(). The latter is not a wrapper around $_SESSION, and thus always returns FALSE, even when masquerading.
Comment | File | Size | Author |
---|---|---|---|
#24 | 2688650-24.patch | 10.79 KB | andypost |
#24 | 2688650-interdiff-23.txt | 1.41 KB | andypost |
#22 | 2688650-interdiff-20.txt | 3.71 KB | andypost |
Comments
Comment #2
mr.baileysPatch attached. Session is injected into the Masquerade constructor.
MasqueradeWebTestBase::assertNoSessionByUid()
andMasqueradeWebTestBase::assertNoSessionByUid()
still rely on the fact that session information is stored in the {sessions} table, and query that table directly. They also use $_SESSION since php'ssession_decode()
is required for unserialization, and it merges into the existing $_SESSION.If you'd prefer the testing to be session storage-agnostic, we can set up a route in a test module to dump the session info and use that for the assertions?
Comment #3
andypostI think in long run we need to get rid of session storage details in tests
Overall code is great, just test fails again
Comment #4
andypostTests are broken because of redirect #2448707-11: Fix masquerade tests
Comment #5
andypostLooks that only possible way to know session details...
Comment #6
andypostRe-roll + clean-up
Comment #8
Ruslan PiskarovI don't know why the test fails, maybe as @andypost mentioned in#4, however
switch_from_using-2688650-6.patch
works well for me.Reviewed and tested manually on my site.
Thank you @andypost.
Comment #9
andypostClean-up patch, added code comments and factored "switchUser" code
Comment #10
andypostComment #12
andypostProper patch
Comment #13
joelpittet@andypost does the dev branch tests need to be repaired first?
Comment #14
andypost@joelpittet I used to try fix them in #2448707: Fix masquerade tests but no success
then I started to check if getting rid of global can help but ... same
Comment #15
andypostqueued to retest https://www.drupal.org/node/49383/qa
Comment #16
Ruslan Piskarov@andypost, in fact, the Unit tests totally were broken and always will fail. Maybe we should review and commit Unit tests before. What do you think about? I added the patch on https://www.drupal.org/project/masquerade/issues/2923960.
Comment #18
andypostComment #19
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Valuebound commentedComment #20
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Valuebound commentedHi,
Please Review the patch.
Thanks!!
Comment #22
andypostClean-up code comments & fix tests
Symfony stores data in separate bag
Comment #23
andypostA bit more polishing
Comment #24
andypostRemove unused changes
Comment #25
andypostComment #27
andypostI went ahead and commited current patch, if any bugs will be found report them separate issues
Comment #30
DanChadwick CreditAttribution: DanChadwick commentedProbably warrants a change record and a BREAKING note in the release notes since themes may have been using $_SESSION to influence theming.
Comment #31
andypostThanks, good point, not sure it makes sense now (after 2 years of commit)... but yes, there's interface change as well
Comment #32
andypostFurther changes to session storage