Problem
-
When creating a distribution profile that only specifies e.g. Block module as a dependency, then installation succeeds, but when visiting the site, you get the following fatal error on
/user/1
:Fatal error: Class 'Drupal\entity\Entity\EntityViewDisplay' not found
in \core\lib\Drupal\Core\Entity\EntityViewBuilder.php on line 225
Cause
-
Entity module does not get installed.
-
This happens, because
install_profile_info()
assumes that the array returned bydrupal_required_modules()
would include the installation profile as the first element, so it usesarray_shift()
to remove the element. -
But when installing with a distribution profile,
install_profile_info()
happens to get invoked before$install_state['parameters']['profile']
is set, sodrupal_get_profile()
does not return a "current" profile (yet). -
In turn, the
array_shift()
causes the Entity module to get removed instead of the assumed installation profile module.
Proposed solution
-
Use
array_diff()
instead ofarray_shift()
.
Comment | File | Size | Author |
---|---|---|---|
distro.profile-info-required.0.patch | 1.17 KB | sun | |
Comments
Comment #1
tstoecklerMakes the code much clearer. Nice!
Comment #2
sunWas that an RTBC? :)
FWIW, even though I'd have an idea for testing this, that would be an extremely narrow DUTB test, which would only test for this particular bug... — Therefore, I thought it wouldn't be worth to add that test here.
Instead of such a too narrow test, I think we need to (1) revamp the architecture of install profile [info] and (2) introduce proper test coverage as part of #2186491: [meta] D8 Extension System: Discovery/Listing/Info
That is, because only after cowboy-debugging this via
debug_backtrace()
, I learned that the entire surrounding code is some giant plate of spaghetti, sans sauce.Comment #3
tstoecklerWell, I'd want to either step through this with a debugger or at least have another pair of eyes look at this so it was intentional that I didn't RTBC (yet).
Comment #4
sunWhen stepping through this with a debugger, note that you might need an actual distribution profile in your filesystem.
The code path is triggered by
install_begin_request()
on line 392:Where
_install_select_profile()
performs:install_profile_info()
calls intodrupal_required_modules()
, which contains:→ But as visible in the first snippet, the
'profile'
parameter is not set yet, sodrupal_get_profile()
returns no profile name and thus the resulting list does not contain a profile.Instead, the first element in the returned array is simply the first 'required' module that has been discovered.
Comment #5
sundistro.profile-info-required.0.patch queued for re-testing.
Comment #6
BerdirYeah, we did run into this with an actual distributation, can confirm that the patch fixes it.
Core currently doesn't have a distribution and I guess can't (otherwise it would override the other install profiles ;)) so this can't be tested. I will certainly notice now if it will break again ;)
Comment #7
catchCommitted/pushed to 8.x, thanks!