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.
Hi.
Problem/Motivation
While migrating a D8.8 site to D9, I encountered the following error while installing the site:
Missing required key (base_theme) in profiles/[...]/mytheme.theme/mytheme.theme
Took me a bit of time to realize the missing key was not base_theme
as stated in the error message but base theme
(without "_").
Steps to reproduce
- Create a simple D9 project
- Remove "base theme" keys from themes'
.info.yml
files. - Run the install process via
drush site-install
. - Expected result: The site install fails with an error message stating the key "base theme" is missing.
- Actual result: The site install fails with an error message stating the key "base_theme" is missing.
Proposed resolution
Update the error message so it reflects the actual missing key.
Comment | File | Size | Author |
---|---|---|---|
#6 | 3146567-6.patch | 1.82 KB | alexpott |
#6 | 2-6-interdiff.txt | 1.82 KB | alexpott |
#2 | wrong-missing-key-name-base-theme-3146567-2.patch | 1.73 KB | pacproduct |
Comments
Comment #2
pacproduct CreditAttribution: pacproduct commentedHere is a pach, as a fix suggestion.
Comment #3
mjpa CreditAttribution: mjpa commentedCame across this just now. Added
base_theme
as it suggested and still error'd. Patch looks good to me.Comment #4
andypostComment #5
catchGood find, looks ready to go to me. Updating the issue title to make it clearer this is just a string issue.
Comment #6
alexpottThis is my fault. Sorry. I broke this in #3098250: Remove all @deprecated code in \Drupal\Core\Extension. Looking back at this I think I removed a bit too much of the message. I think we should add
See https://www.drupal.org/node/3066038
to the message as people are going to encounter this whilst upgrading so a link to the relevant CR feels pertinent.Comment #7
pacproduct CreditAttribution: pacproduct commentedHey @alexpott :)
Good idea, adding a link to www.drupal.org/node/3066038 would really be helpful.
Considering what's in https://www.drupal.org/project/drupal/issues/3118957 should we not avoid using
sprintf
?Comment #8
alexpottThe performance of a single sprintf if generating an exception is not really going to matter. If you hit this you have to fix it and then you'll never see it. For me, using sprintf() here makes the code easier to read and check that the link is correct. Which seems better to prioritise in this case.
Comment #9
pacproduct CreditAttribution: pacproduct commentedFair enough!
Looks good to me then.
Comment #10
xmacinfoI have never found that
sprintf
is easier to read in any piece of PHP I read.But you are right, displaying an exception using
sprintf()
or dot concatenation does not matter performance-wize.Comment #11
andypostIn my background
sprintf()
is a place where often people displace strings and placeholdersComment #14
catchWe don't have a standard on sprintf in exception messages or not (also not sure we should since sometimes 'it depends').
Committed/pushed to 9.1.x and cherry-picked to 9.0.x, thanks!