Problem/Motivation
When you install in a foreign language, the Bartik theme appears to be installed, but styles are seriously broken. This is easily reproduced on simplytest.me, just select a non-English language on installation.
This is due to ThemeHandler::refreshInfo() not using addTheme() to add the theme.
Proposed resolution
Use addTheme() in refreshInfo(). We can also fix a non-qualified todo as well. Add tests.
Remaining tasks
Review. Commit.
User interface changes
Drupal will look sane in a foreign language.
API changes
Theme information returned by ThemeHandler (eg. getTheme(), listInfo(), etc) will not contain top level legacy keys for info file derived values like stylesheets, libraries and the theme engine.
Comments
Comment #1
Gábor HojtsyComment #2
Gábor HojtsyWhen turning off CSS/JS caching, it is apparent from the file list that no CSS for Bartik is actually added to the page. Not good [TM].
Comment #3
Gábor HojtsyAlso switching to Seven theme as default works, the Seven styles are added properly to the frontend pages. When setting back to Bartik, it is still broken as before. No cache clearing helps. So this seems like not a systemic problem as Seven seems to work as a frontend theme in the foreign language environment.
Comment #4
Gábor HojtsyOk this is very bizarre. What I noticed is ActiveTheme has no known stylesheets in it, although the theme extension structure in it has all the info. The theme structure is converted to the ActiveTheme class in ThemeInitialization. If I "fix" the code to not looks at these made-up properties of the theme, but instead use the info file structure, then it is "fixed" as in now all four of the CSS files provided in bartik's info file are added to the page (yay, this is not the case before). BUT the page still looks like crap.
This is due to the markup having no resemblence to what Bartik expects:
(note .layout-container has a header) vs. what Bartik outputs normally:
(note #page-wrapper #page has a #header).
Looks like the templates actually used to generate the page are from the system, not Bartik.
Comment #5
Gábor HojtsySo its not just the CSS, but the templates as well. Turning on TWIG debug mode showed no bartik templates are used ever. It keeps using all the built-in templates and has no idea bartik should be used.
Comment #6
sun3 related issues, clarifying issue title.
First question to figure out: Wondering why this only happens when installing in a different language than English?
I suspect that the installer performs an additional operation (i.e., additional module installations for locale/language), which cause the theme info to be primed ahead of time, before the actual theme is installed. Therefore, #2273769 sounds closely related.
Comment #7
Gábor HojtsyI'm not sure the theme is missing, the system DOES know to some degree it uses Bartik. Ie. ActiveTheme knows its bartik (eg. the Extension info in ActiveTheme is fully populated as Bartik), it does not have the stylesheet parsing that are to be removed in #2326407: Remove magic property overloading from Extension class and probably not initialized in other key ways also. So in some ways Drupal does know Bartik is being used, but it is not initialized fully. The workaround in #4 makes the CSS files even used.
Comment #8
Gábor Hojtsy#2330755: ThemeHandler::refreshInfo() should use addTheme instead of setting the extension directly. fixes this but this issue has more info. Closed that as duplicate.
Comment #9
dawehnerI sadly could not figure out how to run the InstallerLanguagePageTest test. Therefore I decided to tackle the actual root of the problem, adding
additional information to the extension object. I am not sure whether this is the right issue to post this patch, though this solves the same issue,
installing in a language still results in having a proper theme.
Comment #10
JeroenTDuplicate issue: #2326555: After Installing drupal with another language as english, all the css of the bartik theme is gone.
Comment #11
vijaycs85may be like this? as the issue is missing css ID.
Comment #14
Gábor Hojtsy@vijaycs85: we don't need another test, we already have 2 that are actually installing in a foreign language, a German and an Arabic. Your test failed because it got a French translated profile selection page and then could not move forward installing. Also it would have failed because you are asserting Bartik CSS IDs, but the test installs with Stark (which does not have any custom templates).
@dawehner: yeah InstallerLanguagePageTest is not the right one to look at, that does not actually install in a foreign language, so would not fail. InstallerTranslationTest and InstallerLanguageDirectionTest are the two which install actually in a foreign language.
In this patch I decided to extend InstallerTranslationTest. Since Stark does not have its own templates, we need to assert for the only CSS file it has. To be able to do that, we need to turn off CSS aggregation. That's all we need for this test. It nicely fails for me without the fix and passes with the fix.
Comment #15
Gábor Hojtsy@dawehner: looking at the patch there are two odd things:
1. The base_theme is still moved up as a special property in addTheme. That sounds like will still be a problem for a foreign language site that uses a base theme based theme on install, right? I can see it is done because there is also base_themes which is computed in ThemeHandler. But then (see point 2).
2. For some reason, the use of addTheme() in refreshInfo() is not in the patch anymore? Looks like it would still be needed for 1, right?
Uploading a patch that also has #8 in it for this.
While rewriting the issue summary noticed that doing all this cleanup here will result in API changes. Not sure we should couple them with fixing a critical bug? Included them in the patch / issue summary for now, but not sure about this.
Comment #18
Gábor HojtsyErm, looks like the interaction of the fixes did not work well in #15. Let's try with only the test and the one line fix from #8.
Comment #21
Gábor HojtsySilly me. Should not assign a NULL to where an object should be. Meh. Now actually uses the code from #8.
Comment #22
dawehnerNice! Let's solve the underlying problem in a follow up.
Comment #23
catchThis is going to conflict with #2329795: Make it possible to add information to theme info files during development - just add the test here?
Comment #24
Gábor HojtsyHere is a patch that has both rolled together. THIS IS NOT FOR COMMIT. The two fixes overlap in the one line fix and this patch should prove if they work well together (they should :). Then it is your choice to commit this one first (patch from #21) or that one first and we can reroll the other one. The patch only version of this patch at #14 is fully up to date, that should pass once #2329795: Make it possible to add information to theme info files during development lands.
I think we want to keep credit, reference to issues in commits, etc. so comitting from each issues looks best to me.
Comment #25
Gábor HojtsyAll right this proves the two patches work well together :) I volunteer to reroll either once the other one lands.
Comment #26
YesCT CreditAttribution: YesCT commented#2329795: Make it possible to add information to theme info files during development went in. :)
Comment #27
Gábor HojtsyReuploading test only patch from #14 then. Should now pass. It did not pass before, see its results originally in #14.
Comment #28
Gábor HojtsyComment #30
catchCommitted/pushed to 8.0.x, thanks!
Comment #31
Gábor HojtsySuperb, thanks!