Commit 23d10a98 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3154506 by Gábor Hojtsy, andrewmacpherson: Check theme info for missing base theme key

parent 1f2e226f
......@@ -354,7 +354,8 @@ final class DeprecationAnalyzer {
$info_files = $this->getSubExtensionInfoFiles($project_dir);
foreach ($info_files as $info_file) {
try {
// Manually add on info file incompatibility to results. Reding
// Manually add on info file incompatibility to results. Reading
// .info.yml files directly, not from extension discovery because that
// is cached.
$info = Yaml::decode(file_get_contents($info_file)) ?: [];
......@@ -364,6 +365,19 @@ final class DeprecationAnalyzer {
continue;
}
$error_path = str_replace(DRUPAL_ROOT . '/', '', $info_file);
// Check for missing base theme key.
if ($info['type'] === 'theme') {
if (!isset($info['base theme'])) {
$result['data']['files'][$error_path]['messages'][] = [
'message' => "The now required 'base theme' key is missing. See https://www.drupal.org/node/3066038.",
'line' => 0,
];
$result['data']['totals']['errors']++;
$result['data']['totals']['file_errors']++;
}
}
if (!isset($info['core_version_requirement'])) {
$result['data']['files'][$error_path]['messages'][] = [
'message' => "Add core_version_requirement: ^8 || ^9 to designate that the module is compatible with Drupal 9. See https://drupal.org/node/3070687.",
......@@ -382,6 +396,7 @@ final class DeprecationAnalyzer {
$result['data']['totals']['file_errors']++;
$result['data']['totals']['upgrade_status_split']['declared_ready'] = FALSE;
}
} catch (InvalidDataTypeException $e) {
$result['data']['files'][$error_path]['messages'][] = [
'message' => 'Parse error. ' . $e->getMessage(),
......
......@@ -133,8 +133,8 @@ class UpgradeStatusAnalyzeTest extends UpgradeStatusTestBase {
$report = $key_value->get('upgrade_status_test_theme');
$this->assertNotEmpty($report);
$this->assertEquals(5 + $base_info_error, $report['data']['totals']['file_errors']);
$this->assertCount(3 + $base_info_error, $report['data']['files']);
$this->assertEquals(6 + $base_info_error, $report['data']['totals']['file_errors']);
$this->assertCount(4 + $base_info_error, $report['data']['files']);
$file = reset($report['data']['files']);
foreach ([0 => 2, 1 => 4] as $index => $line) {
$message = $file['messages'][$index];
......@@ -149,6 +149,11 @@ class UpgradeStatusAnalyzeTest extends UpgradeStatusTestBase {
$file = next($report['data']['files']);
$this->assertEquals('The theme is overriding the "upgrade_status_test_theme_function_theme_function_override" theme function. Theme functions are deprecated. For more info, see https://www.drupal.org/node/2575445.', $file['messages'][0]['message']);
$this->assertEquals(6, $file['messages'][0]['line']);
$file = next($report['data']['files']);
$this->assertEquals('upgrade_status_test_theme.info.yml', basename(key($report['data']['files'])));
$message = $file['messages'][0];
$this->assertEquals("The now required 'base theme' key is missing. See https://www.drupal.org/node/3066038.", $message['message']);
$this->assertEquals(0, $message['line']);
$report = $key_value->get('upgrade_status_test_theme_functions');
$this->assertNotEmpty($report);
......
name: 'Upgrade status test theme'
type: theme
description: 'Theme for testing the deprecations in themes'
description: 'Theme for testing deprecations in themes'
version: VERSION
base theme: false
core_version_requirement: ^8 || ^9
libraries-override:
upgrade_status_test_library/deprecated_library:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment