Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If there is disallowed or malformed HTML in translatable files you will see a warning in installer with a link to dblog to review the fails. This link is not yet available in installer and need to be removed from installer.
Repro case:
- Run D8 installer with German translation.
Comments
Comment #0.0
hass CreditAttribution: hass commenteda
Comment #1
nonsieHere's a screenshot of the said installer message.
The message comes from locale_translate_batch_finished() in core/modules/locale/locale.bulk.inc which is used elsewhere as well:
I'm not sure if there is a decent way to detect when it's run in the install context though?
Comment #2
penyaskitoTagged so it gets noticed by the right people.
Comment #3
hass CreditAttribution: hass commentedThere is a constant we can check
Comment #4
Gábor HojtsyFixing tags. Also the condition already includes a check for dblog module existing. So the link is only printed then, right? At the point this is printed, modules are already enabled, so you could follow the link. *Except* you are not logged in, which is a regression in Drupal 8, no? You used to be logged in at this point in the installer, no?
Comment #5
nonsieAt the point this message is printed the dblog module exists but the user is not yet logged in and therefore able to follow the link to see the details. This is the same screen one would set up site config and user 1.
In D7 the details are printed to the screen instead of dblog. I also believe you are not logged in at that point yet since this is before setting up the user account/site config.
Assuming that the user should not be logged in at this point in D8, the correct solution should be either outputting the message directly or updating the copy without the link? IMHO the user should know something didn't work quite right but there's no way to find out except to finish the site install.
Comment #6
Gábor HojtsyAll right, that makes sense :) Indeed our best is probably we should check for installer constants / "is maintenance mode".
Comment #7
nonsieAttached patch checks if the batch is run in the maintenance mode, specifically if it is run as part of the installer.
To test run the installer in Estonian ("Eesti" in the language selection). There's one string that has an issue and I have not yet fixed in order to be able to replicate this bug in the installer.
Comment #8
nonsieComment #9
Gábor HojtsyThe fix looks fine :) As good as the (ugly) installer stuff can get :)
This is not clear to me: "There's one string that has an issue and I have not yet fixed in order to be able to replicate this bug in the installer." Can you elaborate?
Comment #10
nonsieThere's a translation in Estonian that contains disallowed/malformed HTML which will cause the message to pop up in the installer in the first place. I administer the Estonian language translation, therefore I could go and fix it but for the sake of this issue I have not yet done it. Does that explain it?
I don't know if this link will work for you but this is the string causing the issue - https://localize.drupal.org/translate/languages/et/translate?project=&st.... The original string is
<No value>
Comment #11
Gábor HojtsyRight, makes sense, looks good :)
Comment #12
webchickCan we add a test for this? It seems like protection against malformed translations should be something we'd want to catch, regardless of where the problem lies.
Comment #13
pp CreditAttribution: pp commentedComment #14
pp CreditAttribution: pp commentedThe core/update.php update_results_page() function contains a same use case and solution.
I rerolled the patch see comment above.
I will add a test soon.
Comment #15
pp CreditAttribution: pp commentedHere it is a patch with tests and a little typo (One files -> One file)
Comment #16
pp CreditAttribution: pp commentedComment #18
Aron Novak- // The import should have created 0 string and rejected 0.
It's a bit strange that we remove this comment, but there's no replacement. What does that assertion test then?
Also, let's use \Drupal\Core\Session\AccountInterface::hasPermission() , as i see there's no reason to use the deprecated style.
That's what i see so far.
Comment #19
pp CreditAttribution: pp commented@Aron Novak Thanks your review
1. I corrected the patch. Change user_access() to \Drupal::currentUser()->hasPermission().
2. It is an ugly copy/pasted comment from above. This assertion tells you the empty file not imported. If you want it, I put it back. :)
pp
Comment #20
pp CreditAttribution: pp commentedComment #22
penyaskitoComment #23
penyaskitoRerolled.
Comment #24
penyaskitoAdapted to code style in HEAD.
Comment #25
vijaycs85Looks good. One minor comment/question
message says couldn't not be imported and assert says empty file imported successfully?
+1 to RTBC.
Comment #26
penyaskitoCorrected #25 and replicated a comment for clarifying assertion.
Comment #27
Gábor HojtsyComment #28
alexpottNo need for the = NULL and this needs an @var annotation.
We should describe why switching users is important to the test
Too many new lines and we should describe why logging in is important here.
Edit: removed incorrect comment
Comment #29
penyaskitoHandled feedback from #28.
Comment #30
Gábor Hojtsyan user => a user
Comment #31
penyaskitoFixed the typo.
Comment #32
Gábor HojtsyLooks good, resolves concerns raised.
Comment #35
Gábor HojtsyRandom db fails. Hope better this time :D
Comment #36
alexpottCommitted 2a95441 and pushed to 8.0.x. Thanks!
Comment #38
Gábor HojtsyThanks all!
Comment #40
alimac CreditAttribution: alimac commentedMinor tag cleanup - please ignore.