Following the issue on https://github.com/drush-ops/drush/issues/3380 which states a Kernel error 'Container cannot be saved to cache.' might occur when invoking drush updb we throw an additional error when asking for getRealMethod on 'null' (empty request stack).

Error: Call to a member function getRealMethod() on null in Drupal\jsonlog\Logger\JsonLog->prepareLog()

Although being an edge case we should check if we're dealing with a http-request before asking getRealMethod() on the RequestStack. Maybe we should also inject this RequestStack via DI instead of making the static call to Drupal::request().

Proposed solution is not trying to log the real method (GET,POST,..) if the actual request from context is unknown meaning an empty $context['request_uri'] or Drupal::request().

Comments

lorenzs created an issue. See original summary.

lorenzs’s picture

Issue summary: View changes
lorenzs’s picture

Status: Active » Needs review
StatusFileSize
new8.51 KB

Attached patch solves this issue and also replaces deprecated getMock in Unit-tests.
I will add this in 1.1 release shortly.

  • lorenzs committed 622efad on 8.x-1.x
    Issue #2954891 by lorenzs: fix logging for unknown http requests.
    
jopdebeeck’s picture

Status: Needs review » Reviewed & tested by the community

Fixed after patch was applied.

lorenzs’s picture

Status: Reviewed & tested by the community » Fixed

Available in release 8.x-1.1.

Status: Fixed » Closed (fixed)

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