Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Issue summary: View changes

a

nonsie’s picture

Issue summary: View changes
FileSize
114.26 KB

Here's a screenshot of the said installer message.
Screenshot

The message comes from locale_translate_batch_finished() in core/modules/locale/locale.bulk.inc which is used elsewhere as well:

if (\Drupal::moduleHandler()->moduleExists('dblog')) {
  $message = format_plural($skips, 'One translation string was skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', '@count translation strings were skipped because of disallowed or malformed HTML. <a href="@url">See the log</a> for details.', array('@url' => url('admin/reports/dblog')));
        }

I'm not sure if there is a decent way to detect when it's run in the install context though?

penyaskito’s picture

Issue tags: +D8MI, +language-base, +sprint

Tagged so it gets noticed by the right people.

hass’s picture

There is a constant we can check

Gábor Hojtsy’s picture

Issue tags: -language-base, -sprint +language-ui

Fixing 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?

nonsie’s picture

At 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.

Gábor Hojtsy’s picture

All right, that makes sense :) Indeed our best is probably we should check for installer constants / "is maintenance mode".

nonsie’s picture

FileSize
1.03 KB

Attached 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.

nonsie’s picture

Status: Active » Needs review
Gábor Hojtsy’s picture

The 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?

nonsie’s picture

There'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>

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix

Right, makes sense, looks good :)

webchick’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs tests

Can 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.

pp’s picture

pp’s picture

The core/update.php update_results_page() function contains a same use case and solution.

 // Report end result.
  if (\Drupal::moduleHandler()->moduleExists('dblog') && user_access('access site reports')) {
    $log_message = ' All errors have been <a href="' . base_path() . '?q=admin/reports/dblog">logged</a>.';
  }
  else {
    $log_message = ' All errors have been logged.';
  }

I rerolled the patch see comment above.

I will add a test soon.

pp’s picture

Here it is a patch with tests and a little typo (One files -> One file)

pp’s picture

Issue tags: +#SprintWeekend2014

The last submitted patch, 13: dblog_link_problem_in_installer-2062103-12.patch, failed testing.

Aron Novak’s picture

Status: Needs review » Needs work

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

pp’s picture

@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

pp’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 19: dblog_link_problem_in_installer_with_tests-2062103-19.patch, failed testing.

penyaskito’s picture

penyaskito’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.52 KB

Rerolled.

penyaskito’s picture

Adapted to code style in HEAD.

vijaycs85’s picture

Looks good. One minor comment/question

+++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
@@ -79,14 +86,33 @@ public function testStandalonePoFile() {
+    $this->assertRaw(t('One translation file could not be imported. See the log for details.'), 'The empty translation file was successfully imported.');

message says couldn't not be imported and assert says empty file imported successfully?

+1 to RTBC.

penyaskito’s picture

Corrected #25 and replicated a comment for clarifying assertion.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +sprint
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
diff --git a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
index cd1575f..011e9c1 100644
<ol>

<li>
<code>
+++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
@@ -30,6 +30,12 @@ class LocaleImportFunctionalTest extends WebTestBase {
   /**
+   * A user able to create languages, import translations and access site
+   * reports.
+   */
+  protected $adminUserAccessSiteReports = NULL;
+

No need for the = NULL and this needs an @var annotation.

  • +++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
    @@ -79,16 +86,35 @@ public function testStandalonePoFile() {
    +    $this->drupalLogin($this->adminUserAccessSiteReports);
    ...
    +    $this->drupalLogin($this->adminUserAccessSiteReports);
    

    We should describe why switching users is important to the test

  • +++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
    @@ -79,16 +86,35 @@ public function testStandalonePoFile() {
     
    +
    +    $this->drupalLogin($this->adminUser);
    

    Too many new lines and we should describe why logging in is important here.

  • Edit: removed incorrect comment

    penyaskito’s picture

    Status: Needs work » Needs review
    FileSize
    7.79 KB
    2.82 KB

    Handled feedback from #28.

    Gábor Hojtsy’s picture

    Status: Needs review » Needs work

    an user => a user

    penyaskito’s picture

    Status: Needs work » Needs review
    FileSize
    7.79 KB
    2.43 KB

    Fixed the typo.

    Gábor Hojtsy’s picture

    Status: Needs review » Reviewed & tested by the community

    Looks good, resolves concerns raised.

    Status: Reviewed & tested by the community » Needs work

    The last submitted patch, 31: 2062103-skipped_translation-31.patch, failed testing.

    Gábor Hojtsy’s picture

    Status: Needs work » Reviewed & tested by the community

    Random db fails. Hope better this time :D

    alexpott’s picture

    Status: Reviewed & tested by the community » Fixed

    Committed 2a95441 and pushed to 8.0.x. Thanks!

    • alexpott committed 2a95441 on 8.0.x
      Issue #2062103 by penyaskito, pp, nonsie | hass: Fixed Skipped...
    Gábor Hojtsy’s picture

    Issue tags: -sprint

    Thanks all!

    Status: Fixed » Closed (fixed)

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

    alimac’s picture

    Issue tags: -#SprintWeekend2014 +SprintWeekend2014

    Minor tag cleanup - please ignore.