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

Reference: https://www.drupal.org/core/beta-changes
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.

Comments

adam clarey’s picture

Patch attached

willzyx’s picture

Status: Active » Needs review
dawehner’s picture

Issue tags: +Needs beta evaluation

Seems to be an improvement for me. Do you mind adding a quick beta evalutation?

sqndr’s picture

Issue tags: +Needs documentation

Let's also make sure the documentation gets updated.

sqndr’s picture

I'll add the beta evalutation.

sqndr’s picture

Issue summary: View changes
Issue tags: +TX (Themer Experience)
sqndr’s picture

I'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

adam clarey’s picture

Has this been committed yet?

star-szr’s picture

Status: Needs review » Needs work

@Adam Clarey no not yet. Thanks for the bump, here's a quick thing that can be addressed.

+++ b/core/modules/system/system.admin.inc
@@ -413,7 +413,7 @@ function template_preprocess_system_themes_page(&$variables) {
+        $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));

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

lauriii’s picture

Issue tags: +Novice
joshi.rohit100’s picture

Status: Needs work » Needs review
StatusFileSize
new1.01 KB
naveenvalecha’s picture

Status: Needs review » Reviewed & tested by the community

Direct change.No disruption.Only documentation change.
RTBC +1

davidhernandez’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1016 bytes

The 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.

joshi.rohit100’s picture

Shouldn't we use short array syntax ?

davidhernandez’s picture

@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.

davidhernandez’s picture

StatusFileSize
new4.52 KB

Updated 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.

sqndr’s picture

+1 for this last patch.

davidhernandez’s picture

@sqndr, feel free to review and RTBC it then. ;)

star-szr’s picture

Title: Give better explanation why a theme in incompatable in D8 » Improve theme compatibility error message

All 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?

davidhernandez’s picture

Category: Bug report » Task

No, 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.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

For me its good

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: give_better_explanation-2489830-16.patch, failed testing.

tr’s picture

'!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.

dcmul’s picture

Status: Needs work » Needs review
StatusFileSize
new3.47 KB
new3.42 KB

Based 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.

star-szr’s picture

Status: Needs review » Needs work

@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.

Also, I believe its pointless to replace !placeholder with @placeholder is one place and not deal with all occurrences with in the entire file.

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.

davidhernandez’s picture

Ok, 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?

star-szr’s picture

I think so.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new1011 bytes

Please review.

cilefen’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs tests
StatusFileSize
new75.74 KB

There 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.

davidhernandez’s picture

Looking at this now with Chris. I agree. These should be two different checks.

cilefen’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new256.46 KB
new1017 bytes
new4.24 KB

The last submitted patch, 31: improve_theme-2489830-31-FAIL.patch, failed testing.

lauriii’s picture

Status: Needs review » Needs work

Looks 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?

davidhernandez’s picture

Issue tags: -Needs documentation

I assume the theming guide. This page already mentions that 'content' region is required. https://www.drupal.org/node/2349827

lauriii’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community

Fixed beta evaluation. Otherwise this is all good.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 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.

  • alexpott committed f1e618e on 8.0.x
    Issue #2489830 by cilefen, davidhernandez, dcmul, Adam Clarey, joshi....

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.