Problem/Motivation
A theme needs the core: 8.x tag. It's also required to have a content region. The current error message can be confusing and doesn't give much information:
'This version is not compatible with Drupal 8.x and should be replaced.'
Proposed resolution
Improve the error message:
$current_theme['incompatible'] = t('This version is not compatible with Drupal !core_version and should be replaced. Check the .info.yml file contains the correct \'core\' value and that the theme includes a region called \'content\'.', array('!core_version' => \Drupal::CORE_COMPATIBILITY));
Remaining tasks
None.
User interface changes
None.
API changes
None.
Beta phase evaluation
| Issue category | Tasks because it's just improving the error message. |
|---|---|
| Issue priority | Not critical. |
| Unfrozen changes | Unfrozen because it only changes the messages given in an error situation |
| Prioritized changes | The main goal of this issue is improving the TX which is not prioritized. |
| Disruption | Change is not disruptive at all |
Original issue:
I'd built a custom theme that worked perfectly well in beta 10, i then setup a new site from the latest 8.0.x branch.
I copied the theme into the new site and on the theme config page (admin/appearance) the theme was uninstallable and just had the description:
'This version is not compatible with Drupal 8.x and should be replaced.'
This give me no explanation as to my previously working theme no longer was usable. After spending some time stepping through the code, I found the line in SystemController.php line 233:
$theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != \DRUPAL::CORE_COMPATIBILITY) || !isset($theme->info['regions']['content']);
From this i was able to see its because my theme didn't have a region labelled 'content' (I personally can't see why this is a hard requirement, but hey...).
I could have saved myself some valuable time if the error message just included an extra sentence to say why the theme wasn't compatible.
I've attached a patch that just adds the text 'Check the .info.yml file contains the correct 'core' value and that the theme includes a region called 'content'.
I think will save a lot of people a lot of time and eliminate a lot of confusion.
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | improve_theme-2489830-31.patch | 4.24 KB | cilefen |
| #31 | improve_theme-2489830-31-FAIL.patch | 1017 bytes | cilefen |
| #31 | Screen Shot 2015-07-18 at 4.25.30 PM.png | 256.46 KB | cilefen |
| #29 | Screen Shot 2015-07-18 at 4.08.07 PM.png | 75.74 KB | cilefen |
| #28 | 2489830-28.patch | 1011 bytes | rpayanm |
Comments
Comment #1
adam clarey commentedPatch attached
Comment #2
willzyx commentedComment #3
dawehnerSeems to be an improvement for me. Do you mind adding a quick beta evalutation?
Comment #4
sqndr commentedLet's also make sure the documentation gets updated.
Comment #5
sqndr commentedI'll add the beta evalutation.
Comment #6
sqndr commentedComment #7
sqndr commentedI've updated the documentation:
core: 8.x is required - but this documentation was already there.
Content region is required - added this to the documentation.
#2349827: Defining a theme with an .info.yml file
Comment #8
adam clarey commentedHas this been committed yet?
Comment #9
star-szr@Adam Clarey no not yet. Thanks for the bump, here's a quick thing that can be addressed.
Maybe wrap the string with double quotes so you don't have to escape the single quotes. See https://www.drupal.org/coding-standards#quotes
Comment #10
lauriiiComment #11
joshi.rohit100Comment #12
naveenvalechaDirect change.No disruption.Only documentation change.
RTBC +1
Comment #13
davidhernandezThe second sentence didn't quite read right. It was missing prepositions.
I removed the "...and should be replace." part of the first sentence. It doesn't make sense to first say the theme should be replaced, and then say check for compatibility issues. The first sentence is implying the theme is D7 or older, which we're no longer assuming.
Comment #14
joshi.rohit100Shouldn't we use short array syntax ?
Comment #15
davidhernandez@joshi, sure. If changing it, I would probably change all the array syntax the same function, so it is consistent. We don't have solid rules for this, though.
Comment #16
davidhernandezUpdated the array syntax in the function. Hopefully, no typos. This is part of the problem with changing the array syntax. We start making out of scope changes that distract us from the issue at hand. This shouldn't be too much of a change though, so I think we're ok.
Comment #17
sqndr commented+1 for this last patch.
Comment #18
davidhernandez@sqndr, feel free to review and RTBC it then. ;)
Comment #19
star-szrAll the short array stuff for the parts that aren't being touched is out of scope here IMO. If I had to pick one I would take #13, especially because it's 1/4 the size of the latest patch.
Is this really a bug?
Comment #20
davidhernandezNo, there is no software bug and the current comment isn't incorrect. We're adding additional info to make clearer, so I'd call that a task.
Comment #21
lauriiiFor me its good
Comment #23
tr commented'!core_version' should be replaced with '@core_version', see #2506427: [meta] !placeholder causes strings to be escaped and makes the sanitization API harder to understand
I agree with @Cottser (#19) that the array() / [] stuff is out of scope and should be addressed in another issue.
Comment #24
dcmul commentedBased on the comments #19 and #23 about the array stuff, I worked off #13. We will add the array stuff if most think differently
Also, I believe its pointless to replace !placeholder with @placeholder is one place and not deal with all occurrences with in the entire file.
Comment #25
star-szr@dcmul thanks for the patch! I don't think we should be bulk replacing !placeholder with @placeholder, IMO that's really no different from the mass short array conversion we had. It makes the patch hard to review, it's harder to see what the actual relevant change is and makes it less likely that this type of issue will get committed.
If this were my own project, in terms of version control I would separate those changes into two commits. First make the actual functional change which is the reason for this issue, then do any bulk search/replace things in a separate commit. Applying that same philosophy to core means a separate issue, which in this case already exists and is being worked on.
Comment #26
davidhernandezOk, so reroll #13 and replace the array() syntax with the short [] syntax in just that line. Should we also replace the placeholder in that line, but just that line?
Comment #27
star-szrI think so.
Comment #28
rpayanmPlease review.
Comment #29
cilefen commentedThere should be two different errors, one for the region and one for the core version, or it is oddly confusing.
The message says "This version is not compatible with Drupal 8.x. Check that the .info.yml file contains the correct 'core' value and the theme includes a region called 'content'." It should actually read "This theme is not compatible ...".
It is easy to write a test for this so I am doing that.
Comment #30
davidhernandezLooking at this now with Chris. I agree. These should be two different checks.
Comment #31
cilefen commentedComment #33
lauriiiLooks good! The patch is RTBC but we still need some information to beta-evaluation. There is also Needs Documentation tag, does anyone know what for?
Comment #34
davidhernandezI assume the theming guide. This page already mentions that 'content' region is required. https://www.drupal.org/node/2349827
Comment #35
lauriiiFixed beta evaluation. Otherwise this is all good.
Comment #36
alexpottCommitted f1e618e and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation. I agree this is a change that benefits theme developers and the benefits outweigh the disruption of committing the patch.