- π¨πSwitzerland znerol
Re #59
but what about CLIs like drush and console. They don't have a session either so are we in danger of making things more difficult for them?
We could add a session object backed by an in-memory store in
DrupalKernel::preHandle()
. This is sufficient for command line tools and tests. Web requests will be processed by\Drupal\Core\StackMiddleware\Session
where the mock session is replaced by a session object backed with persistent storage and a real session handler.This works with current
drush php:script
and the following snipped:var_dump(\Drupal::request()->hasSession());
The last submitted patch, 70: 2484991-add-the-session-70.patch, failed testing. View results β
- π¨πSwitzerland znerol
Session stack middleware should avoid attempting to save a session it didn't start.
- π¨πSwitzerland znerol
Re #65
PS: see interdiff - few tests removed
$request->setSession($this->getSessionFromRequest());
but passedThat is expected. All those calls were added for consistency reasons. The goal in this issue is that every
Request
in core has aSession
. We only can hope that people start copying the$request->setSession($this->getSessionFromRequest());
pattern if it is applied consistently throughout core. - π¨πSwitzerland znerol
Switching this issue to MR workflow. I'm probably going to test another idea in a separate branch as well.
- @znerol opened merge request.
The last submitted patch, 72: 2484991-72.patch, failed testing. View results β
- Merge request !3320Issue #2484991: Add the session to the request in KernelTestBase / BrowserTestBase β (Closed) created by znerol
- Status changed to Needs work
almost 2 years ago 4:59pm 28 January 2023 - π«π·France andypost
Left few comments, primary is to fix deprecation message according standard https://www.drupal.org/about/core/policies/core-change-policies/drupal-d... β
43 failed tests! Great job!
- Status changed to Needs review
almost 2 years ago 1:11pm 29 January 2023 - π¨πSwitzerland znerol
Updated the issue summary in order to reflect the new approach.
- Status changed to RTBC
almost 2 years ago 3:02pm 29 January 2023 - Status changed to Needs work
almost 2 years ago 3:28pm 27 February 2023 - πΊπ¦Ukraine voleger Ukraine, Rivne
I set it to Needs work due to unresolved threads in MR.
- Status changed to Needs review
almost 2 years ago 4:17pm 27 February 2023 - π¨πSwitzerland znerol
Thanks. Extracted two methods for session initialization in order to better document their responsibility and purpose:
DrupalKernel::initializeEphemeralSession()
StackMiddleware\Session::initializePersistentSession()
- Status changed to RTBC
almost 2 years ago 8:36am 28 February 2023 - πΊπ¦Ukraine voleger Ukraine, Rivne
All review comments are addressed.
- πΊπ¦Ukraine voleger Ukraine, Rivne
bump
As soon as will be merged, that will unblock π Remove DrupalKernel::initializeRequestGlobals and replace base_root, base_url and base_path with a service Needs work - Status changed to Needs work
over 1 year ago 7:04am 17 April 2023 - π³πΏNew Zealand quietone
The change record for this issue has no text. Adding tag and setting to NW.
- Status changed to Needs review
over 1 year ago 8:06am 17 April 2023 2:44 2:03 Running- Status changed to Needs work
over 1 year ago 8:08am 17 April 2023 - π³πΏNew Zealand quietone
Apologies to all for my rather terse comment.
@znerol, thanks for updating the CR.
- Status changed to Needs review
over 1 year ago 8:09am 17 April 2023 - π³πΏNew Zealand quietone
Setting this to NW was unintentional. Sorry for the noise.
- Status changed to RTBC
over 1 year ago 8:32am 17 April 2023 - last update
over 1 year ago 29,287 pass - πΊπΈUnited States dww
MAINTAINERS.txt has this for the "base system" "subsystem" [sic]:
Base system - ?
- It's weird that the "base system" is considered a "subsystem" (out of scope for this issue, obviously). π
- There is no dedicated subsystem maintainer for "base system". In this case, I think a "framework manager" review would be most appropriate.
- @alexpott already reviewed, but let's be explicit that a framework manager reviews this and signs off before commit.
- Status changed to Needs work
over 1 year ago 10:46pm 19 April 2023 - πΊπΈUnited States dww
Doing a review of the MR. Found some issues. Will save that soon so they appear here, but downgrading to NW now...
- last update
over 1 year ago 29,287 pass - last update
over 1 year ago 29,287 pass - last update
over 1 year ago 29,287 pass - Status changed to Needs review
over 1 year ago 11:05pm 19 April 2023 - πΊπΈUnited States dww
Pushed a commit to fix all my own nits and the deprecation message typo. Also edited the CR to fix the same typo there. π I'd resolve most of the threads I just opened (if I could). The two that should remain open until addressed are:
- πΊπΈUnited States dww
WHOOPS! Holy cross-posting and cross-pushing, batman. π’ Sorry, @andypost! Was trying to resolve my own stuff, didn't see you were already responding. Yikes. I'll stop now and let the dust settle before I do anything else... π
- π«π·France andypost
NP, As I see the only debatable moment left is https://git.drupalcode.org/project/drupal/-/merge_requests/3320#note_168867
I think it could be solved with π Requests are pushed onto the request stack twice, popped once Needs work
- last update
over 1 year ago CI aborted - last update
over 1 year ago 29,264 pass, 2 fail - πΊπΈUnited States dww
Per Slack chat w/ @andypost, we agreed a
@todo/@see
comment pointing to π Requests are pushed onto the request stack twice, popped once Needs work was worth adding to justify the switch torebuildContainer()
...All new threads should now be resolved. This is ready for framework manager review, although I can't re-RTBC it now. π
- last update
over 1 year ago 29,287 pass - last update
over 1 year ago 29,287 pass - πΊπΈUnited States dww
Posted in #needs-review-queue-initiative to solicit the framework manager review this needs, so tagging for that. π
- last update
over 1 year ago 29,287 pass - πΊπΈUnited States dww
Re-queue'ed PHP 8.1 + MySQL 5.7 - random fail β in
Ckeditor5.Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest
.
- πΊπΈUnited States dww
: Opened π cspell does not flag "ist" as a typo Fixed to deal with the cspell vs. "ist" weirdness.
- Status changed to RTBC
over 1 year ago 10:21pm 20 April 2023 - last update
over 1 year ago 29,306 pass 15:14 11:42 Running- last update
over 1 year ago 29,304 pass - last update
over 1 year ago 29,366 pass - last update
over 1 year ago 29,370 pass - last update
over 1 year ago 29,371 pass - last update
over 1 year ago 29,378 pass - last update
over 1 year ago 29,383 pass - last update
over 1 year ago 29,384 pass - last update
over 1 year ago 29,384 pass - last update
over 1 year ago 29,364 pass, 2 fail - last update
over 1 year ago 29,392 pass - last update
over 1 year ago 29,392 pass - last update
over 1 year ago 29,392 pass - last update
over 1 year ago 29,392 pass - Open on Drupal.org βEnvironment: PHP 8.1 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass - last update
over 1 year ago 29,400 pass - last update
over 1 year ago 29,403 pass 30:14 26:46 Running- last update
over 1 year ago 29,404 pass - Status changed to Needs work
over 1 year ago 8:26pm 30 May 2023 - πΊπ¦Ukraine voleger Ukraine, Rivne
Needs to change branch in MR, and update versions in deprecation messages
10.1.0
->10.2.0
- last update
over 1 year ago 29,448 pass - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
over 1 year ago Waiting for branch to pass - Status changed to Needs review
over 1 year ago 7:49pm 18 July 2023 - π¨πSwitzerland znerol
Rebased on 11.x and adapted the deprecation messages.
- last update
over 1 year ago 29,826 pass - π³π±Netherlands daffie
Looks good to me.
The MR does what the IS states.
For me it is RTBC. - Status changed to RTBC
over 1 year ago 7:55am 20 July 2023 - last update
over 1 year ago 29,831 pass - last update
over 1 year ago 29,883 pass - last update
over 1 year ago 29,883 pass - last update
over 1 year ago 29,888 pass - last update
over 1 year ago 29,890 pass - last update
over 1 year ago 29,891 pass, 1 fail - last update
over 1 year ago 29,894 pass, 1 fail - last update
over 1 year ago 29,895 pass, 1 fail - πΊπ¦Ukraine voleger Ukraine, Rivne
π cspell does not flag "ist" as a typo Fixed is merged in 11.x
- last update
over 1 year ago 29,929 pass, 1 fail - last update
over 1 year ago 29,936 pass, 1 fail - last update
over 1 year ago 29,936 pass, 1 fail - last update
over 1 year ago 29,936 pass, 1 fail - last update
over 1 year ago 29,941 pass, 1 fail - last update
over 1 year ago 29,941 pass, 1 fail - last update
over 1 year ago 29,942 pass, 1 fail - last update
over 1 year ago 29,942 pass, 1 fail - last update
over 1 year ago 29,950 pass, 1 fail - last update
over 1 year ago 30,032 pass, 1 fail - last update
over 1 year ago 30,039 pass, 1 fail - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
This looks awesome. π I could only find 3 language nits, for which I left suggestions.
- last update
over 1 year ago 30,039 pass, 1 fail - last update
over 1 year ago 30,039 pass, 1 fail - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 30,060 pass - last update
over 1 year ago 30,062 pass - last update
over 1 year ago 30,064 pass - last update
over 1 year ago 30,067 pass - last update
over 1 year ago 30,134 pass - last update
over 1 year ago 30,139 pass - last update
over 1 year ago 30,140 pass - last update
over 1 year ago 30,140 pass - last update
over 1 year ago 30,140 pass - last update
over 1 year ago 30,150 pass - Status changed to Needs work
over 1 year ago 2:26am 11 September 2023 - π³πΏNew Zealand quietone
Sorry folks, The change record has an an incorrect branch, version and example deprecation message. And the deprecation message in the MR needs a change to conform to coding standards. I have left suggestions in the MR.
- last update
over 1 year ago 30,150 pass - last update
over 1 year ago 30,150 pass - Status changed to Needs review
over 1 year ago 10:59am 11 September 2023 - Status changed to RTBC
over 1 year ago 11:51am 11 September 2023 - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
over 1 year ago Not currently mergeable. - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
over 1 year ago Not currently mergeable. - Open on Drupal.org βEnvironment: PHP 8.2 & MySQL 8last update
over 1 year ago Not currently mergeable. - last update
over 1 year ago 30,172 pass - last update
over 1 year ago 30,172 pass - last update
about 1 year ago 30,209 pass - last update
about 1 year ago 30,212 pass - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,424 pass - last update
about 1 year ago 30,424 pass - last update
about 1 year ago 30,430 pass - last update
about 1 year ago 30,438 pass - last update
about 1 year ago 30,442 pass - last update
about 1 year ago 30,460 pass - last update
about 1 year ago 30,476 pass - last update
about 1 year ago 30,479 pass, 1 fail - last update
about 1 year ago 30,490 pass - last update
about 1 year ago 30,490 pass - last update
about 1 year ago 30,492 pass - last update
about 1 year ago 30,516 pass - last update
about 1 year ago 30,523 pass - last update
about 1 year ago 30,534 pass - Status changed to Needs review
about 1 year ago 4:03am 15 November 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Both
Request::create
andRequest::createFromGlobals
end up callingRequest::createFromFactory
I wonder if our test setup trait could call
\Symfony\Component\HttpFoundation\Request::setFactory
which would have do the session setup for all of those instances. It won't helpnew Request
but those should probably be using::create
or::createFromGlobals
anyway.It would mean the size of the change here is much smaller, and the need for contrib/custom projects to make chances would be reduced.
We could mention in the CR that in most cases they should switch to
::create
or::createFromGlobals
instead of usingnew Request
and setting the session. - π¨πSwitzerland znerol
While maybe convenient, I think that #117 will create more problems than it solves.
In Drupal 7, application code modified the
$_SESSION
superglobal directly. Every piece of code which accessed it was guaranteed to work with the same data. However, using the$_SESSION
directly breaks encapsulation and makes testing difficult. Missing test coverage was probably one of the reasons why π Feature "Remember the last selection" for views exposed filters doesn't work anymore Fixed went unnoticed for quite a long time.In times where
$_SESSION
was used exclusively, the responsibility to populate and store its contents wasSessionManager.php
alone (orsession.inc
in D7). Now that almost all core code is refactored to use theRequest::getSession()
, there are additional code paths involved in passing data form the PHP session to the places where its used and back again.Basically every piece of code which creates, clones, duplicates a request also has the responsibility to copy the session. It is true that many of those are located in test cases, but some can be found in production code paths as well. The latter have the potential to introduce subtle bugs if they do not propagate the session. When everybody used
$_SESSION
this wasn't an issue. Nowadays it is.I fear that installing a request factory in the test system will hide those potential bugs. Code which fabricates a request in order to pass that into non-trivial code paths without propagating the session will seemingly behave correctly in tests (because of the request factory) and will produce invalid requests (i.e., lacking a session) in production.
- Status changed to Needs work
about 1 year ago 11:58am 16 November 2023 The Needs Review Queue Bot β tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs review
about 1 year ago 4:09pm 16 November 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Thank you @znerol that is a very thorough and eloquent explanation of why the disruption is actually better.
I think we probably want to target 10.3.0 with this now, which will mean we need to update the deprecation message. I'll confirm with release managers.
- Status changed to Needs work
about 1 year ago 8:39am 20 November 2023 - π³π±Netherlands daffie
The MR needs to be updated for that this will go in 10.3 instead of 10.2
- Status changed to Needs review
about 1 year ago 10:44am 22 November 2023 - Status changed to RTBC
about 1 year ago 12:41pm 22 November 2023 - last update
about 1 year ago 30,609 pass - last update
about 1 year ago 30,671 pass - last update
about 1 year ago 30,679 pass - last update
about 1 year ago 30,683 pass - Status changed to Needs work
about 1 year ago 5:31am 30 November 2023 The Needs Review Queue Bot β tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs review
about 1 year ago 9:00pm 30 November 2023 - πΊπΈUnited States dww
Hah, whoops, cross rebase. π But no harm done.
- Status changed to RTBC
about 1 year ago 3:58pm 1 December 2023 - πΊπΈUnited States smustgrave
Appear all threads have been addressed and no tests appear to be breaking.
CR is full of detail (branch versions need to be bumped)
- last update
about 1 year ago 30,692 pass - πΊπΈUnited States dww
Edited the CR to bump the versions to 10.3.0.
- last update
about 1 year ago 30,692 pass - last update
about 1 year ago 30,692 pass - last update
about 1 year ago 30,700 pass - last update
about 1 year ago 30,702 pass - last update
about 1 year ago 30,716 pass - last update
about 1 year ago 30,728 pass - last update
about 1 year ago 30,768 pass 45:15 40:13 Running- last update
about 1 year ago 25,953 pass, 1,815 fail -
larowlan β
committed 48a7cf12 on 11.x
Issue #2484991 by znerol, voleger, andypost, dww, anmolgoyal74,...
-
larowlan β
committed 48a7cf12 on 11.x
- Status changed to Fixed
about 1 year ago 12:27am 22 December 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Went through this again, only found one out of scope change, that I reverted locally before committing.
@alexpott's concerns in #31, #32 and #59 were addressed by @znerol by a change of approach.
My point in #117 was addressed in #118
We know this could be disruptive so I think getting it in early in the 10.3 cycle is the best approach.
So on that basis, committed and pushed to 11.x
Published the change record.
Thanks everyone for the mammoth effort over a prolonged period here.
Special thanks to @znerol for your patient and thorough explanations when required.
-
larowlan β
committed 7393eba2 on 11.x
Revert "Issue #2484991 by znerol, voleger, andypost, dww, anmolgoyal74,...
-
larowlan β
committed 7393eba2 on 11.x
- Status changed to Needs work
about 1 year ago 2:00am 22 December 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Sorry folks, I had to revert this as it caused failure in HEAD
Looks like there's a new test that creates a Request but doesn't push a session
See \Drupal\Tests\file\Kernel\RequirementsTest::setServerSoftware
Fine to self RTBC
I'll keep an eye out for changes
- Assigned to znerol
- Status changed to RTBC
about 1 year ago 8:23am 22 December 2023 - last update
about 1 year ago 25,894 pass, 1,812 fail - Status changed to Needs work
about 1 year ago 9:40am 22 December 2023 - π¨πSwitzerland znerol
Oh, I might have overwritten work done by @voleger and @dww by basing off my changes on an outdated local branch. Let me fix that.
- Status changed to RTBC
about 1 year ago 10:01am 22 December 2023 - last update
12 months ago 25,913 pass, 1,823 fail - last update
12 months ago 25,961 pass, 1,792 fail -
larowlan β
committed fbee2baa on 11.x
Issue #2484991 by znerol, voleger, andypost, dww, anmolgoyal74,...
-
larowlan β
committed fbee2baa on 11.x
- Status changed to Fixed
12 months ago 10:04pm 27 December 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Thanks, compared the two patches locally and confirmed the only difference was this
diff --git a/core/modules/file/tests/src/Kernel/RequirementsTest.php b/core/modules/file/tests/src/Kernel/RequirementsTest.php index 4d472644dc4..224616e089b 100644 --- a/core/modules/file/tests/src/Kernel/RequirementsTest.php +++ b/core/modules/file/tests/src/Kernel/RequirementsTest.php @@ -7,6 +7,8 @@ use Drupal\KernelTests\KernelTestBase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\HttpFoundation\Session\Session; +use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; /** * Tests the file requirements. @@ -69,6 +71,7 @@ public function testUploadRequirements(): void { */ private function setServerSoftware(?string $software): void { $request = new Request(); + $request->setSession(new Session(new MockArraySessionStorage())); if (is_string($software)) { $request->server->set('SERVER_SOFTWARE', $software); }
Committed and pushed to 11.x, re-published the change record.
Thanks for the quick turnaround
- π«π·France andypost
Thank you! Removal of global session remains now unblocked π Convert uses of $_SESSION in forms and batch Needs work
Automatically closed - issue fixed for 2 weeks with no activity.