summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-07-27 12:35:14 +0100
committerAlex Pott2015-07-27 12:35:14 +0100
commitf1e618ec2578f7a26cfdf5c3131c278da3c0166c (patch)
tree6edfcb15cb563bb54bace2eaa23661f7ce3b90f5
parentba1b14e41f764e272f9162905cee2371c832cde1 (diff)
Issue #2489830 by cilefen, davidhernandez, dcmul, Adam Clarey, joshi.rohit100, rpayanm, sqndr, Cottser, lauriii: Improve theme compatibility error message
-rw-r--r--core/modules/system/src/Controller/SystemController.php3
-rw-r--r--core/modules/system/src/Tests/System/ThemeTest.php4
-rw-r--r--core/modules/system/system.admin.inc5
-rw-r--r--core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml5
-rw-r--r--core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml8
5 files changed, 23 insertions, 2 deletions
diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php
index 20ea39e..6bae397 100644
--- a/core/modules/system/src/Controller/SystemController.php
+++ b/core/modules/system/src/Controller/SystemController.php
@@ -241,9 +241,10 @@ class SystemController extends ControllerBase {
if (empty($theme->status)) {
// Ensure this theme is compatible with this version of core.
+ $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != \DRUPAL::CORE_COMPATIBILITY);
// Require the 'content' region to make sure the main page
// content has a common place in all themes.
- $theme->incompatible_core = !isset($theme->info['core']) || ($theme->info['core'] != \DRUPAL::CORE_COMPATIBILITY) || !isset($theme->info['regions']['content']);
+ $theme->incompatible_region = !isset($theme->info['regions']['content']);
$theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0;
// Confirmed that the base theme is available.
$theme->incompatible_base = isset($theme->info['base theme']) && !isset($themes[$theme->info['base theme']]);
diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php
index 84745b7..7c85275 100644
--- a/core/modules/system/src/Tests/System/ThemeTest.php
+++ b/core/modules/system/src/Tests/System/ThemeTest.php
@@ -273,6 +273,10 @@ class ThemeTest extends WebTestBase {
$this->drupalGet('admin/appearance');
$this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => 'not_real_test_basetheme')));
$this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => 'not_real_engine')));
+ // Check for the error text of a theme with the wrong core version.
+ $this->assertText("This theme is not compatible with Drupal 8.x. Check that the .info.yml file contains the correct 'core' value.");
+ // Check for the error text of a theme without a content region.
+ $this->assertText("This theme is missing a 'content' region.");
}
/**
diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc
index 1141a35..cc91849 100644
--- a/core/modules/system/system.admin.inc
+++ b/core/modules/system/system.admin.inc
@@ -420,7 +420,10 @@ function template_preprocess_system_themes_page(&$variables) {
// Make sure to provide feedback on compatibility.
$current_theme['incompatible'] = '';
if (!empty($theme->incompatible_core)) {
- $current_theme['incompatible'] = t('This version is not compatible with Drupal !core_version and should be replaced.', array('!core_version' => \Drupal::CORE_COMPATIBILITY));
+ $current_theme['incompatible'] = t("This theme is not compatible with Drupal @core_version. Check that the .info.yml file contains the correct 'core' value.", ['@core_version' => \Drupal::CORE_COMPATIBILITY]);
+ }
+ elseif (!empty($theme->incompatible_region)) {
+ $current_theme['incompatible'] = t("This theme is missing a 'content' region.");
}
elseif (!empty($theme->incompatible_php)) {
if (substr_count($theme->info['php'], '.') < 2) {
diff --git a/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml b/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml
new file mode 100644
index 0000000..5c369a6
--- /dev/null
+++ b/core/modules/system/tests/themes/test_invalid_core/test_invalid_core.info.yml
@@ -0,0 +1,5 @@
+name: 'Theme test with invalid core version'
+type: theme
+description: 'Test theme which has an invalid core version.'
+version: VERSION
+core: 7.x
diff --git a/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml b/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml
new file mode 100644
index 0000000..6fef32a
--- /dev/null
+++ b/core/modules/system/tests/themes/test_invalid_region/test_invalid_region.info.yml
@@ -0,0 +1,8 @@
+name: 'Theme test with missing content region'
+type: theme
+description: 'Test theme which has a non-existent content region.'
+version: VERSION
+core: 8.x
+
+regions:
+ - foo: Foo