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.
As Drupal is going to use a recent version of Symfony (2.4/2.5/2.6?), it should use the request stack to access the current/master request. Using it allows to remove the need for the request service in the container (and that's a good thing because the request is not a service anyway). This also allows Drupal to get rid of the request scope altogether (a side-effect is a slightly performance improvement.)
Comment | File | Size | Author |
---|---|---|---|
#82 | 80-82-interdiff.txt | 947 bytes | alexpott |
#82 | 2284103-berdir.82.patch | 103.44 KB | alexpott |
#80 | 2284103-berdir.80.patch | 102.4 KB | alexpott |
#78 | 2284103-berdir.78.patch | 103.48 KB | alexpott |
#78 | 76-78-interdiff.txt | 1.25 KB | alexpott |
Comments
Comment #1
fabpot CreditAttribution: fabpot commentedComment #2
fabpot CreditAttribution: fabpot commentedComment #3
fabpot CreditAttribution: fabpot commentedComment #6
fabpot CreditAttribution: fabpot commentedComment #7
fabpot CreditAttribution: fabpot commentedComment #9
fabpot CreditAttribution: fabpot commentedComment #10
fabpot CreditAttribution: fabpot commentedComment #12
fabpot CreditAttribution: fabpot commentedComment #14
fabpot CreditAttribution: fabpot commentedComment #16
fabpot CreditAttribution: fabpot commentedComment #18
fabpot CreditAttribution: fabpot commentedComment #19
Anonymous (not verified) CreditAttribution: Anonymous commentedadding beta-blocker tag - this sort of change probably can't/shouldn't happen after beta.
also, that will get more eyes on this, even if just to remove the tag ;-)
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedright tag this time.
Comment #22
BerdirNot 100% sure but I think this is very similar to #2223189: Use regular upstream HttpKernel instead of Drupal's custom ?
Comment #23
alexpottI like this issue. I don't think we should have both the request and request_stack services defined - it is both confusing and takes code to maintain. However, this issue should not be beta blocking - it does not meet the criteria. However we should aim to get this done as soon as possible. It is critical as I don't think we should release Drupal 8 without this being fixed.
Comment #24
fabpot CreditAttribution: fabpot commentedComment #26
fabpot CreditAttribution: fabpot commentedComment #28
fabpot CreditAttribution: fabpot commentedComment #30
fabpot CreditAttribution: fabpot commentedThe last patch fixes almost all tickets. But I'm not able to fix the last ones; I cannot understand what's going on and the code is too complex to understand easily. Anyone willing to help me?
By the way, I've benchmarked the code, and removing the request scope make the default Drupal homepage a bit faster: 2% (not big, but that's a nice side effect.)
Comment #31
larowlanThis patch breaks the Simpletest UI, fyi.
Was taking a look at the fails and can't get any tests to run via the UI, all failing with
Runs fine via the command-line.
Note that one of the failing tests is SimpleTestTest, so hopefully that means we have coverage for the fact that the UI is broken.
/me keeps digging
Comment #32
XanoI have been getting the same error lately for different reasons, but I have not been able to reproduce the problem consistently.
Comment #33
fabpot CreditAttribution: fabpot commentedComment #34
znerol CreditAttribution: znerol commentedRe #31: this is #2239969: Session of (UI) test runner leaks into web tests which currently is blocked by #2272987: Do not persist session manager.
Comment #35
fabpot CreditAttribution: fabpot commented#34
Does it mean that 8.x tests do not pass in a similar way? If that's the case, would it be possible to merge this patch before the root cause is fixed?
Comment #36
znerol CreditAttribution: znerol commentedRe #35 only the UI test runner is affected, the test-bot isn't.
Comment #37
alexpottSo the good news is that the remaining fails are fixed by other patches.
The patch attached contains all these patches. Also I think we need to do #2272879: Can not run a WebTestBase or KernelTest base tests from inside a simpletest if we're going to do #2272987: Do not persist session manager and #2239969: Session of (UI) test runner leaks into web tests since the last time we committed #2239969: Session of (UI) test runner leaks into web tests we discovered that we were not really testing the UI for the test framework.
Comment #38
Crell CreditAttribution: Crell commentedalexpott: Silly question. If those patches all pass when we merge them together here, how come several are still not RTBC themselves? :-) What's the commit strategy here for this chain?
Comment #39
fabpot CreditAttribution: fabpot commentedThis new patch removes the management of synchornized service in ContainerBuilder (the code was copy/pasted from Symfony but that's not needed anymore.)
Comment #41
fabpot CreditAttribution: fabpot commentedrebase on current 8.x
Comment #42
fabpot CreditAttribution: fabpot commentedComment #43
fabpot CreditAttribution: fabpot commentedAny news on this patch?
Comment #44
Xen CreditAttribution: Xen commentedPatch didn't apply, rebased and fixed two conflicts.
Interdiff might be hosed, interdiff complained.
Comment #46
martin107 CreditAttribution: martin107 commentedregarding #43 @fabpot I suspect people are not posting patches because it assigned to somebody, perhaps try unassigning
Comment #47
fabpot CreditAttribution: fabpot commentedComment #48
XanoI fixed one of the test failures and deleted the test that covered synchronized services, as @fabpot said this is no longer necessary in #39.
Comment #49
alexpottHmmm... but the test shows that we do still need it. If we were not overriding ContainerBuilder::set() to allow us to set services on a frozen container then we would not need it. I looked at trying to remove this override but that would cause this patch to get even bigger.
Also @xano your post was an xpost with mine so interdiff is back to #44.
In order to get this in we need to fix #2272987: Do not persist session manager and #2239969: Session of (UI) test runner leaks into web tests first.
Comment #50
moshe weitzman CreditAttribution: moshe weitzman commentedComment #53
alexpottRerolled.
Had some interesting issues with
DrupalKernel::getContainer()
. This code always calls watchdog until the container can be dumped - but because there is syslog or db_log module enabled this goes no where! In InstallerKernel we currently prevent dumping until the settings.php is written with the hash salt. I've removed this a properly set the allows dumping on DrupalKernel construction by doing:In install.core.inc
We still need #2239969: Session of (UI) test runner leaks into web tests to land. Nearly there.
Comment #55
moshe weitzman CreditAttribution: moshe weitzman commentedAnyone care to push this Critical along? Would be a pity to lose momentum.
Comment #58
Berdir#2239969: Session of (UI) test runner leaks into web tests got in, so here's a re-roll, just a bunch of trivial conflicts due to different comments, empty lines and type safe comparisons.
@moshe: This was blocked on that other issue, there wasn't much to push around here :)
Comment #59
BerdirComment #61
damiankloip CreditAttribution: damiankloip commentedThese are failing from the call to watchdog() in getContainer() as it is not dumped to disk. The watchdog call is then trying to get the user id() in the LoggerChannel:
As the request is only added to the stack in preHandle(), there is no request for AccountProxy > AuthenticationManager to use.
Simplest approach is to not add the id() to the context, and just keep the user. Else, we need to think about either the watchdog call or how the request can be added to the stack. Failure is happening really because the request is not added to the stack.
This should at least isolate and show it passes. Probably not the right solution though.
Comment #63
alexpottDrupalKernelTest was only passing in HEAD because this code
In LoggerChannelFactory ... an exception was being through from $this->container->get('request') because we're getting an unset synthetic service... the request stack is not synthetic so this does not occur anymore.
Comment #64
damiankloip CreditAttribution: damiankloip commentedLooks good!
Do we need to bother checking for a request stack now? We will always have one?Ignore me, looks good!
Comment #65
alexpottCRs that need updating:
Comment #66
alexpottComment #67
ParisLiakos CreditAttribution: ParisLiakos commentedlooks great:)
should obey drupal coding standards.
also some of them miss docs
shouldnt this method now always use the request stack and not store it somewhere? that way we make sure request doesnt get outdated
thats great:) but lets also remove the use statement from the top of the exception
shouldnt we inject the stack instead? that way request wont get outdated
Comment #68
alexpottComment #70
alexpottFixed tests...
Comment #71
ParisLiakos CreditAttribution: ParisLiakos commentedthanks
needs docblock and null should be uppercase
false should be uppercase
null should be uppercase
Comment #72
alexpottThanks - couldn't see it :)
Comment #73
ParisLiakos CreditAttribution: ParisLiakos commentedthanks, this looks really great!
Comment #74
hussainwebNot really a review but more of a series of questions about things I didn't really understand. I'd appreciate it if you can clarify on these.
Should we document why we are using getMasterRequest here, compared to getCurrentRequest everywhere else. It might be important.
Same here.
Shouldn't we use the container to get the request, rather than using \Drupal? This happens in a few other places as well. I am not too sure about this one but I thought I'd bring it up.
Comment #75
dawehnerIs there a reason why the current user is now wrapped inside the request stack condition? I could imagine that there might be no request but a manual set user for CLI scripts
Just in case you have some time please convert that to non-camel-case
This example actually should just push a new request onto the container? It already will have a stack.
Comment #76
alexpott@hussainweb #74
@dawehner #75
Comment #77
catchI think we should add inline docs for #74/#76 #1, needs an explanation there to make it clear what's going on. Didn't spot anything else obvious.
Comment #78
alexpottActually I don't think
Drupal::hasRequest()
has any real reason to use getMasterRequest so lets change that so it maps nicely toDrupal::request()
.Added a comment for the authentication use case.
Comment #80
alexpottNeeded a reroll due to #2196241: Remove string translation services from TestBase container a whole hunk of request and container futzing in TestBase was ripped out. Nice!
Comment #82
alexpottNeed to use request_stack (not request) in the install tests.
Comment #83
catchCommitted/pushed to 8.x, thanks!
Comment #85
sunQuestion:
I've studied this change intensively, but I'm not able to see where & how the
request_stack
gets re-injected into the rebuilt container after a call toDrupalKernel::updateModules()
.It magically appears to exist, and the current
Request
object is the identical object as the one prior to callingupdateModules()
, but somehow I fail to see the responsible lines of code for that (since this patch seemingly removed the code that manually re-injected it).Can someone enlighten me? (Or am I looking at a mystery?)