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.
watchdog() is used by the custom error handler that is set by Drupal. Watchdog() gets the ip address by calling Drupal::request()->getClientIP(), which requires that the service container is set. This makes all errors really serious, since the container is not set yet.
This could possibly also affect other parts of the system which are called early.
Comment | File | Size | Author |
---|---|---|---|
#3 | drupal-move-error-handler-1974570-3.patch | 1.41 KB | fabsor |
Comments
Comment #1
fabsor CreditAttribution: fabsor commentedThere are two ways I can think of to solve this issue:
1. Set the service container in the BOOTSTRAP_CONFIGURATION phase.
2. Modify watchdog and other possible places to check if the container is set where appropriate.
It seems to me that the first choice makes the most sense.
Comment #2
fabsor CreditAttribution: fabsor commentedComment #3
fabsor CreditAttribution: fabsor commentedThe minimal effort is to move the error handler code to the boot phase, after initializing the service container. This not ideal, since we probably want to use our error handler as early in the process as possible, but it would be hard to refactor it to work, but I'm setting this to needs review anyway to get some eyes on it =)
watchdog() uses the service container for getting the ip_address(), but it also calls hook_watchdog through module_implements, which requires the service container as well.
Comment #5
clemens.tolboomSee #1987262: [Installation Error] Symfony: "The service definition 'request' does not exist." calling watchdog.
Comment #6
clemens.tolboomThe definition of class Drupal states it's a
and Drupal::request has even
Should we patch all calls to Drupal::request() or even calls to Drupal::* by using a try-catch construct?
By using #3 we are putting stuff 'under the carpet' I guess.
(my 2 cents)
Comment #7
ParisLiakos CreditAttribution: ParisLiakos commentedrelated
#1289536: Switch Watchdog to a PSR-3 logging framework
Comment #8
Blooniverse CreditAttribution: Blooniverse commented... priority change? For the reason see #1987262: [Installation Error] Symfony: "The service definition 'request' does not exist.".
Comment #9
catchThis looks like a duplicate of #1845646: error_displayable() cannot be converted from variable system safely.