Problem/Motivation

This seems to be a regression of #474684: Allow themes to declare dependencies on modules. The code there has been unchanged since a long time, but now themes have dependencies too and if they depend on another theme without a version (apparently themes don't get a default version key), e.g. when you have a custom theme depending on another custom theme, then you get this php warning:

Notice: Undefined index: version in system_requirements() (line 909 of core/modules/system/system.install).

Proposed resolution

\Drupal\Core\Extension\ModuleExtensionList defines an empty version key as default. The easiest fix is probably to add the same to ThemeExtensionList?

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
542 bytes
dww’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Looks like a good fix. However, I think we'll need a test that tickles the bug before anyone will commit this to core.

tedbow’s picture

@Berdir thanks for creating this issue

I found this other bug while reviewing this issue
#3133657: Themes are allowed in 'dependencies' for other themes

Berdir’s picture

Will try to work on a test, not sure how easily that's possible in core as some default version logic might be applied to anything that core provides?

Berdir’s picture

This adds an explicit test for the ThemeExtensionList service that the version key is set, good enough? Actually testing the system requirements is awkward, doesn't really work in a kernel test it seems. Used an existing theme without version key, apparently we have a few of those.

The last submitted patch, 6: theme-version-3133604-6-tests-only.patch, failed testing. View results

dww’s picture

Status: Needs review » Reviewed & tested by the community

@Berdir Looks great to me. Test-only failed thusly:

There was 1 error:

1) Drupal\KernelTests\Core\Extension\ThemeExtensionListTest::testThemeWithoutVersion
Undefined index: version

That matches the problem described in the summary. Agreed that a more elaborate test for system requirements isn't needed. The fix is incredibly small and trivial. No CS problems.

RTBC!

Thanks,
-Derek

dww’s picture

p.s. Not sure why the bot is struggling with the 8.9.x testing of this. Trying it locally:

a) Patch applies cleanly to a clean 8.9.x git checkout.
b) core/tests/Drupal/KernelTests/Core/Extension/ThemeExtensionListTest.php passes.
c) Reverting the fix to core/lib/Drupal/Core/Extension/ThemeExtensionList.php and the test fails as expected.

/shrug

dww’s picture

Testbot seems to be all kinds of confused. Re-uploading the real patch from #6 in the hopes that this will become the re-tested patch and that it'll actually work on 8.9.x. 🤞

  • xjm committed 4da7958 on 9.1.x
    Issue #3133604 by Berdir, dww: Dependency compatibility check in system...

  • xjm committed dafad70 on 9.0.x
    Issue #3133604 by Berdir, dww: Dependency compatibility check in system...

  • xjm committed 026032b on 8.9.x
    Issue #3133604 by Berdir, dww: Dependency compatibility check in system...

  • xjm committed 9e68b9d on 8.8.x
    Issue #3133604 by Berdir, dww: Dependency compatibility check in system...

  • xjm committed c59b1a8 on 8.8.x
    Revert "Issue #3133604 by Berdir, dww: Dependency compatibility check in...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Oops. I compared ModuleExtensionList and ThemeExtensionList and confirmed this does seem to be the correct fix.

Committed to 9.1.x, and cherry-picked to 9.0.x and 8.9.x as a beta-eligible bugfix. I realized after I committed it that #474684: Allow themes to declare dependencies on modules only landed in 8.9, so there will also be a revert in the messages there on 8.8.x (it'd probably be harmless, but just in case someone was for some reason doing something based on whether the version was set...)

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.