Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
routing system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Mar 2014 at 11:32 UTC
Updated:
29 Jul 2014 at 23:28 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
znerol commentedComment #3
znerol commentedReroll after #1316692: Convert hook_admin_paths() into declarative properties on routes. How do we educate devs to use request stack service instead of request service in new code?
Comment #5
znerol commentedSupposedly the test failures are a result of working with the url generator lacking an appropriate request object in the parent site. As a consequence the global
urlfunction might produce different results for the parent site and the child site.Therefore it may be necessary to setup the request stack in the simpletest parent site, such that a proper
requestis available through therequest_stackservice.Comment #6
znerol commentedThe natural place to inject the request-context into the test-container would be either
TestBase::rebuildContainerorWebTestBase::prepareRequestForGenerator. However none of them works because further down insetUpwe're callingdrupal_flush_all_cachesand that one ends up inDrupalKernel::boot(). In factDrupalKernel::updateModules()reboots the kernel for the reason stated in the following comment:The reason why the
$requestservice is not affected, is that the kernel takes care of restoring it when rebuilding the container. We probably need to do the same for request-context.I think that the proper way to resolve the problem would be to delay booting the kernel until after
WebTestBase::resetAll. However, that does not seem practical given that a lot of services are accessed throughoutWebTestBase::setUp.Comment #7
znerol commentedLet's try that.
Comment #8
znerol commented@dawehner questions the hunk in
WebTestBase::prepareRequestForGenerator. Let's see whether we can live without it.Comment #9
znerol commentedGet rid of custom persist logic for the
router.request_context</service>. The custom logic actually is only required for the <code>requestservice because it potentially is scoped.Persisting
router.request_contextservice actually is necessary because the reasons given in #6: In short we end up with an empty request context and that will affect the URL generator (and thus theurlfunction) in the simpletest parent.Comment #10
znerol commentedComment #11
znerol commentedThe change to
Symfony\Cmf\Component\Routing\ProviderBasedGeneratorwas accidental. Lets revert that and at the same time revert the changes to theDrupal\Core\Routing\UrlGeneratorto restore consistency with CMF.Comment #13
znerol commentedSilly me, failed to add the '@'-character to one of the container service references.
Comment #14
znerol commentedComment #15
znerol commentedComment #16
znerol commentedReroll, no changes.
Comment #17
znerol commentedReroll after #2229223: RequestStack is not persisted across kernel rebuilds
Comment #18
znerol commentedComment #19
dawehnerIs there a reason for this change? Does that mean that the router listener ensures that?
Comment #20
znerol commentedUpon closer inspection the change to the url generator service definition does not seem to be strictly required as part of this patch. Let's try and revert that change.
Exactly. In 2.3 mode, the request stack is not injected into the router listener. The router listener therefore cannot possibly update the request context by itself. Whereas in 2.4 mode the router listener does maintain the request context from within a
KernelEvents::REQUESThandler. (see RouterListener::onKernelRequest()). In the simpletest parent site we still need to update the request context manually. Before this was done upon synchronization of the request service - i.e. whenever something called\Drupal::service('request')->set(...).Comment #21
znerol commentedComment #22
znerol commentedUh, no test results, let's trigger a test-run.
Comment #23
dawehner.
Comment #25
znerol commented20: 2223593-use-request-stack-in-router-20.diff queued for re-testing.
Comment #26
znerol commentedThis looks like a testbot failure. Retest and back to RTBC.
Comment #28
znerol commentedReroll.
Comment #29
dawehnerre-rtbc
Comment #30
tim.plunkettHaven't read the issue yet... Just putting it where people can find it.
Comment #31
alexpottCommitted 775184c and pushed to 8.x. Thanks!