Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Status: Needs review » Needs work

The last submitted patch, drupal8.error-handler-container.0.patch, failed testing.

sun’s picture

Status: Needs work » Needs review
dawehner’s picture

#2160655: Improve error handling of \Drupal class seems also to be an related.

In general hasService('request') seems to also return TRUE, if the request is not set yet onto the container, see Container::has() and getRequestService() on the container. Maybe we should fill an upstream bug report?
At least for request we might actually want to use IntrospectableContainerInterface::initialized() instead?

sun’s picture

we might actually want to use IntrospectableContainerInterface::initialized() instead?

I'm not sure how that would look code-wise in this function? — bear in mind that we can't make any assumptions or rely on anything in the error handler.

For now, I'd recommend to go ahead with this patch; it certainly resolves the last remaining WTFs in our procedural error handler.

In the end, this entire code will (hopefully) be replaced by completely new error/exception handler code in (or attached to) DrupalKernel.

dawehner’s picture

FileSize
17.76 KB

Well, there is a semantic difference between has and initialized. While it does not matter for most services it does matter for the request one, see the attached screenshot.

so if we fail during booting or don't have a request at all, we might not fix those issues.

For now, I'd recommend to go ahead with this patch; it certainly resolves the last remaining WTFs in our procedural error handler.

Given that has('request') will always return TRUE we could at least try to check for IntrospectableContainerInterface.

dawehner’s picture

For now, I'd recommend to go ahead with this patch; it certainly resolves the last remaining WTFs in our procedural error handler.

In the end, this entire code will (hopefully) be replaced by completely new error/exception handler code in (or attached to) DrupalKernel.

You cannot argue against that, sure.

sun’s picture

If I get you right, then we'd have to amend that condition to be

if (\Drupal::hasService('request') && \Drupal::getContainer()->isScopeActive('request') && ...)

?

dawehner’s picture

We do we not simply use something like:

if (\Drupal::hasService('request') &&
  // Or introduce a new method on \Drupal
  ($container = \Drupal::getContainer();) && $container->initialized('request')) {
sun’s picture

OK, a helper method on \Drupal makes sense to me. Let's simply do both for now? We can always adjust it later. :-)

dawehner’s picture

+1 for now.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

+1 for now.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed e71d749 and pushed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.