Updated: Comment #N
Problem/Motivation
If you trigger a PHP warning too early during Drupal's install (or boot?) process (for example, in file_directory_os_temp, see #2110863: Support open_basedir) then watchdog() will throw an InvalidArgumentException with the message
The service definition "module_handler" does not exist
.
This will bubble up through:
_drupal_log_error()
_drupal_error_handler_real()
_drupal_error_handler()
and eventually cause the user to see #2091501: When install fails: Fatal error: Call to undefined function theme() in install.core.inc on line 954
Proposed resolution
Consider if we can safely and usefully handle the error in the watchdog() function.
If not, then catch and discard the error, as we do for other errors in that function.
Remaining tasks
Decide on approach
Write patch
User interface changes
None
API changes
An undocumented exception is less likely to be thrown.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2153401-1-option-b-watchdog-exception.patch | 2.67 KB | ianthomas_uk |
| #2 | 2153401-1-option-a-watchdog-exception.patch | 1.03 KB | ianthomas_uk |
| #1 | 2153401-1-demonstrate-bug-do-not-test.patch | 545 bytes | ianthomas_uk |
Comments
Comment #1
ianthomas_ukHere is an example patch to trigger the problem. With this applied, I see
(if you see a different error, check #2091501: When install fails: Fatal error: Call to undefined function theme() in install.core.inc on line 954)
Comment #2
ianthomas_ukI've attached two patches. Option A is as specific as possible so only catches this known exception. Option B assumes that watchdog should never throw any exceptions, so catches anything that might be thrown while $in_error_state is true. I prefer option B as I don't see why you'd want watchdog() to throw exceptions, but I'm interested in other opinions.
With either of the above patches applied, that error becomes
Comment #3
ianthomas_ukComment #6
ianthomas_uk2: 2153401-1-option-b-watchdog-exception.patch queued for re-testing.
Comment #8
ianthomas_uk2: 2153401-1-option-b-watchdog-exception.patch queued for re-testing.
Comment #10
sunI think my patch in #2194111: Error handler throws exception when service container is not (fully) available yet fixes the root cause, which should also resolve this issue?
Comment #11
jhedstromNeeds confirmation that ##1 resolves the issue.
Comment #12
larowlanPretty sure #2509898: Additional uncaught exception thrown while handling exception after service changes would resolve this