Problem/Motivation
We currently show any theme that is added on the Appearance page. This results in a page that is highly convoluted and mixes base themes, admin themes and themes you actually wish to install.
In Drupalcon Barcelona conversations we expect this to become an even bigger problem out of the box. We want to disallow people choosing "Classy" as their theme and placing a block in it. This is completely non-sensical.
Proposed resolution
We propose to add a new YAML property:
+hidden: true
This allows us to hide the theme for selection in the Appearance page, for placing blocks in the Block UI and in Theme Settings. However if the hidden theme is the default theme then it is still display on the Block UI and Theme Settings page. This means we don't have to worry about sites which are currently using Stable or Classy as their default theme.
This issue blocks #2581443: Make Classy extend from the new Stable base theme
Remaining tasks
User interface changes
We don't show base themes on the Apperance page, Blocks UI, or Theme settings, unless the base theme is the default theme.
API changes
block_themes_installed() does not auto create block placements for hidden themes.
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #51 | 2574975-new-51.patch | 26.77 KB | alexpott |
| #51 | 50-51-interdiff.txt | 1.33 KB | alexpott |
| #50 | 2574975-new-50.patch | 26.21 KB | alexpott |
| #50 | 49-50-interdiff.txt | 1.74 KB | alexpott |
| #49 | 2574975-new-49.patch | 25.34 KB | alexpott |
Comments
Comment #2
joelpittetComment #3
xjmThe previous issue title really confused me. ;)
Comment #4
izus commentedhi,
there is also the 'hidden' key that can be used.
following patch uses it to hide test themes from the UI.
Comment #5
lauriiiWe don't want to hide themes but instead be able to not allow them being enabled as is e.g base themes
Comment #8
joelpittet@lauriii we also want to hide them from the block UI example but they need to be available to the the sub-themes.
Comment #9
lauriii@joelpittet: How should the markup of these themes be tested?
Comment #10
Bojhan commentedComment #11
lewisnymanI would prefer it if we had a
theme_typekey with the valuebase. It has a semantic meaning and opens the door to use adding more values likeadminornon_adminso we can prevent people from selecting admin themes as frontend and vice-versa.I'm not saying we should do that work here but the key we choose would affect this. What do you think?
Comment #12
star-szrComment #13
alexpottDiscussed with @catch and we agreed that this is an rc target and eligible for commit during the rc-phase. This is an key UI and with the addition of stable it will get even more unnecessarily complex. This was not an issue in D7 because base themes did not have to be installed.
Comment #14
star-szrI think we should try to determine the scope of what we're really talking about here. I think @izus is on to something and that we could probably use the hidden property to hide it from the Appearance UI.
But then we want to also:
Comment #15
webchickI love the idea of re-using
hidden: true; making themes more like modules FTW.I also think #14 sounds good; "hidden" = hidden from the UI, and that would include all UIs which list themes (which in core is only admin/appearance and admin/structure/block afaik). I think that hiding them from the UI therefore also prevents them from being enabled / default (except maybe by some fancy drush magic, but that'd be outside of core), by definition.
Comment #16
star-szrOne problem I'm seeing is that if we hide these base themes from the UI it's really difficult to uninstall them if they're no longer being used.
Comment #17
dawehnerWhat about hiding it unless all their child themes are uninstalled?
Comment #18
webchickWell, I'd rather handle this the way users would expect, which is if you uninstall a front-end/admin theme, and its parent base theme has no other active themes depending on it, Drupal uninstalls the base theme as well.
While that's very risky to do in the case of modules, given uninstall inherently = data loss, here we're deliberately removing the ability to add block configurations, etc. to base themes so I think it's safe?
Comment #19
star-szrYeah I'm more in favour of handling it behind the scenes like that.
Comment #20
Bojhan commentedAlright, this makes most sense. This is in the end *magic* that users don't need to be aware of. Even for themers its not really relevant. When there theme depends on a base theme its always installed, when that theme is installed.
Comment #21
webchickOk cool, spun off a separate issue for that since it has nothing to do with UI hiding: #2581385: Automagically uninstall unused base themes when sub themes are uninstalled.
FWIW catch thinks it's not a huge deal and we don't need to block this patch on that one. There's a workaround (use Drush) and these "phantom" themes shouldn't represent a huge performance suck.
Comment #22
star-szrI was playing around with this a few days ago, uploading a patch to get things started. I can't remember how far I got with the tests so uploading two patches to see the delta in test fails.
No interdiff from the earlier patch since there is no commonality.
Comment #25
alexpottWe shouldn't be listing hidden themes in the block ui either. And also this means we can't use classy as a theme for testing.
Comment #27
alexpottFixed all the test fails.
Comment #28
alexpottWrong interdiff
Comment #30
alexpottFix more of the tests and add some for the Block UI and base themes not appearing.
Comment #31
star-szrThanks very much @alexpott!
Minor: Can probably just remove 'cannot' here.
This seems like it's not needed, if it is maybe it needs a comment.
Comment #32
alexpottThanks @Cottser. Fixed both points.
Comment #33
star-szrI can't find any faults here and I really like how this cleans up Classy. I think test_classy is a very good idea.
Do we want to also hide these themes from /admin/appearance/settings (theme settings)? Just want to make sure we discuss that.
And I just want to mention that I tested it and it's still possible to uninstall Classy/Stable/other hidden base themes via Drush as long as themes depending on them are uninstalled first. If you're creative you can also do this via the UI.
Comment #34
alexpottYes we do also want to hide these themes from admin/appearance/settings
Comment #35
duaelfrThe #32 patch works perfectly.
I think we should also hide these themes from admin/appearance/settings as #33 suggested.
We might also want a setting to allow to see these themes again. We already have
$settings['extension_discovery_scan_tests']for test themes and modules. Why not something for hidden themes (and modules)?Comment #36
alexpottPostponed #2581443: Make Classy extend from the new Stable base theme on this issue.
Also I think 403's are the wrong responses from the BlockUI when trying to access Classy or Stable. It implies there is some permission that can be granted that would give the user access. There is no permission.
Comment #37
alexpottPatch in #36 fixes theme settings for the hidden base themes.
Comment #38
alexpottThe only remaining question is what about sites that have blocks and theme settings for Classy and Stable on existing sites. It is possible that someone has set classy to be their default theme. The patch in #36 would break the functionality of their site - and I don't think we should do that. So... new approach that leads to a smaller patch.
Comment #39
alexpottSo the one funky thing about the patch in #38 is that if you were to change the default away from Classy or Stable then it would just disappear. Not sure what we should do about that.
Comment #41
star-szrWith that approach should we also be checking if it's set as the admin theme?
Should this be checking hasUi now?
Comment #42
alexpottOkay so the problem I alluded to in #30 causes a few test fails. But they are all easy to fix and the fixes reduce our test dependency on classy so looking good imo.
Comment #43
alexpott@Cottser - excellent point yes!
The massive advantage of the new approach is that it means we don't have to try to stop people from setting these base themes as admin or default themes.
Comment #44
alexpottAh @Cottser actually no... there is no point here because this only happens on theme install there so it can;t be default or admin at this point - unless it is the first theme in which case there are no blocks to copy so...
Comment #46
alexpottFixing the last test fail.
Comment #47
alexpottThe interdiff on #46 was skewiff...
Comment #48
star-szrMostly docs nitpicks, it's definitely nice that this patch is less than half the size of the earlier version and also doesn't mess with folks who might be directly using these themes.
I think this comment could be a bit more accurate if it's going to be used in a few places, maybe change "or not found" to "or is hidden from the UI".
Curious why these are installed separately, maybe it merits a comment.
Minor: I think this should be s/are unavailable/is unavailable/
Minor: s/vlaid/valid/
Minor: s/are avialable/is available/
Very minor: s/Install/install/
Comment #49
alexpottI also removed the unneeded router rebuild setting in ThemeController::setDefaultTheme() cause the config event does that for us - as it should.
Comment #50
alexpottAdded missing test coverage for the change to
block_themes_installed(). Plus decided to use ThemeHandler::hasUi() because it is less reaching inside the theme's info array and plucking stuff out and it is nicely self documenting.Comment #51
alexpott#50 is gonna fail because
base_themeis a custom theme I have lying around. lolz.Comment #53
star-szrShip it! hasUi is much cleaner and this does everything it should now and has good test coverage. The config event thing is very nice too.
Comment #54
catchI'd normally expect this to be done in the access callback, but there's something to be said for it being a 404 semantically.
No other comments really, so committed/pushed to 8.0.x, thanks!
Comment #57
Bojhan commentedeh, can we have a followup for the UI part?
Comment #58
star-szr@Bojhan sorry which part do you mean?