Skip to content
Snippets Groups Projects
Commit e06c4610 authored by catch's avatar catch
Browse files

Issue #304540 by Rob Loach, marcingy, typhonius, BrockBoland, jaredsmith:...

Issue #304540 by Rob Loach, marcingy, typhonius, BrockBoland, jaredsmith: Fixed Disable themes when theme engine or base theme arn't available.
parent ed1d937f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -231,4 +231,14 @@ function testSwitchDefaultTheme() {
$this->drupalGet('admin/structure/block');
$this->assertText('Stark(' . t('active tab') . ')', t('Default local task on blocks admin page has changed.'));
}
/**
* Test that themes can't be enabled when the base theme or engine is missing.
*/
function testInvalidTheme() {
module_enable(array('theme_page_test'));
$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')), 'Invalid base theme check succeeded.');
$this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => 'not_real_engine')), 'Invalid theme engine check succeeded.');
}
}
......@@ -156,10 +156,14 @@ function system_themes_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_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']]));
// Confirm that the theme engine is available.
$theme->incompatible_engine = (isset($theme->info['engine']) && !isset($theme->owner));
}
$query['token'] = drupal_get_token('system-theme-operation-link');
$theme->operations = array();
if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php) {
if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) {
// Create the operations links.
$query['theme'] = $theme->name;
if (drupal_theme_access($theme)) {
......@@ -2725,6 +2729,12 @@ function theme_system_themes_page($variables) {
}
$output .= '<div class="incompatible">' . t('This theme requires PHP version @php_required and is incompatible with PHP version !php_version.', array('@php_required' => $theme->info['php'], '!php_version' => phpversion())) . '</div>';
}
elseif (!empty($theme->incompatible_base)) {
$output .= '<div class="incompatible">' . t('This theme requires the base theme @base_theme to operate correctly.', array('@base_theme' => $theme->info['base theme'])) . '</div>';
}
elseif (!empty($theme->incompatible_engine)) {
$output .= '<div class="incompatible">' . t('This theme requires the theme engine @theme_engine to operate correctly.', array('@theme_engine' => $theme->info['engine'])) . '</div>';
}
else {
$output .= theme('links', array('links' => $theme->operations, 'attributes' => array('class' => array('operations', 'clearfix'))));
}
......
name = "Theme page test"
description = "Support module for theme system testing."
package = Testing
version = VERSION
core = 8.x
<?php
/**
* Implements hook_system_info_alter().
*/
function theme_page_test_system_info_alter(&$info, $file, $type) {
// Make sure that all themes are visible on the Appearance form.
if ($type == 'theme') {
unset($info['hidden']);
}
}
/**
* Implements hook_system_theme_info().
*/
function theme_page_test_system_theme_info() {
$themes['test_invalid_basetheme'] = drupal_get_path('module', 'system') . '/tests/themes/test_invalid_basetheme/test_invalid_basetheme.info';
$themes['test_invalid_engine'] = drupal_get_path('module', 'system') . '/tests/themes/test_invalid_engine/test_invalid_engine.info';
return $themes;
}
\ No newline at end of file
name = Theme test with invalid base theme
description = Test theme which has a non-existent base theme.
core = 8.x
base theme = not_real_test_basetheme
hidden = TRUE
name = Theme test with invalid theme engine
description = Test theme which has a non-existent theme engine.
core = 8.x
hidden = TRUE
engine = not_real_engine
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment