Commit 2fb3a051 authored by alexpott's avatar alexpott

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