Updated: Comment #N
Problem/Motivation
The installation process sometimes fails with the error message
"Fatal error: Call to undefined function theme() in xxx/core/includes/install.core.inc on line 1009."
The install_drupal
function tries to catch exceptions thrown by install_begin_request
using install_display_output
, however install_display_output
returns a themed page, and the theme system is only loaded during install_begin_request
. Therefore, if an exception is thrown too soon, the user will get the above error message (triggered on the penultimate line of install_display_output).
This was spotted while working on #2110863: Support open_basedir amoung other instances.
Proposed resolution
Check the theming system is ready before using it and/or have another error handler ready to handle an error thrown by the theming system.
Remaining tasks
Decide on approach
Write patch
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#4 | 2091501-4-undefined-function-theme.patch | 850 bytes | ianthomas_uk |
#4 | 2091501-4-example-exception-do-not-test.diff | 541 bytes | ianthomas_uk |
Comments
Comment #1
Alan D. CreditAttribution: Alan D. commentedI was easily able to replicate with an existing settings.php file that contained a reference to an existing database that was empty.
Removing the file allowed installation to get to the first page of the install successfully.
Removing the $databases['default']['default'] but keeping the rest of the settings.php file as is, gave an "Drupal already installed" message (file was from a post Drupal 8 alpha 2 install from memory).
Comment #2
ianthomas_ukUpdating summary using the template and a more technical description of what is happening.
Original summary
When the install of Drupal 8 fails it (might) fail(s) with the message:
Fatal error: Call to undefined function theme() in drupal\core\includes\install.core.inc on line 954
There are other issues that do mention this error message, but they focus on eliminating a specific case that lead to the install procedure to fail. This issue should make sure that the install fails with a proper message to the user (the message that probably was themed when this error occurs) not with this fatal.
Note: in my case it was an already existing settings.php, a situation that before, IIRC, was handled with a correct message.
Comment #3
Alan D. CreditAttribution: Alan D. commentedFrom #2110863-9: Support open_basedir
Note that in my case open_basedir was not set. There may be multiple entry points to getting this same error.
Comment #4
ianthomas_ukHere's a patch that will just rethrow the exception instead of attempting to display a nicely themed page if that's not going to possible.
Instead of
the user will see
Hopefully the exception message will help them solve their problem, but at the very least it will lead them to a better place to start debugging. I've also uploaded a patch to throw an exception that would trigger this problem, for review purposes.
Comment #5
sunPlease note that #2176105: Installer catches exceptions and manually re-prints them; does not use error/exception handler fixes the error/exception handler for the installer, which removes the code in question here.
Comment #6
xjm4: 2091501-4-undefined-function-theme.patch queued for re-testing.
Comment #8
BerdirLooking at the code, I think this has been refactored elsewhere so that this no longer happens.