Skip to content
Snippets Groups Projects
Commit 2fb3a051 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2594937 by Peacog, cilefen, Sagar Ramgade, chgasparoto, aerozeppelin,...

Issue #2594937 by Peacog, cilefen, Sagar Ramgade, chgasparoto, aerozeppelin, iStryker, feraline, alvar0hurtad0, Cottser, Wim Leers, xjm, sebas5384, almaudoh, gvso, racarvalho1987: Empty 'libraries:' in theme .info.yml file produces confusing PHP warning
parent c572b924
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
......@@ -198,8 +198,10 @@ public function listInfo() {
* {@inheritdoc}
*/
public function addTheme(Extension $theme) {
foreach ($theme->info['libraries'] as $library => $name) {
$theme->libraries[$library] = $name;
if (!empty($theme->info['libraries'])) {
foreach ($theme->info['libraries'] as $library => $name) {
$theme->libraries[$library] = $name;
}
}
if (isset($theme->info['engine'])) {
$theme->engine = $theme->info['engine'];
......
name: 'Test theme libraries empty'
type: theme
description: 'Test theme with empty libraries in theme.info.yml'
version: VERSION
base theme: classy
core: 8.x
libraries:
......@@ -137,6 +137,20 @@ public function testRebuildThemeData() {
$this->assertEquals(array('seven/global-styling'), $info->info['libraries']);
}
/**
* Tests empty libraries in theme.info.yml file.
*/
public function testThemeLibrariesEmpty() {
$theme = new Extension($this->root, 'theme', '/core/modules/system/tests/themes/test_theme_libraries_empty', 'test_theme_libraries_empty.info.yml');
try {
$this->themeHandler->addTheme($theme);
$this->assertTrue(TRUE, 'Empty libraries key in theme.info.yml does not cause PHP warning');
}
catch (\Exception $e) {
$this->fail('Empty libraries key in theme.info.yml causes PHP warning.');
}
}
/**
* Tests rebuild the theme data with theme parents.
*/
......
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