Problem/Motivation

In a multilingual site if you add a comment on a node which is in the default language, everything is okay.
But if you add a comment on a node which is not in the default language, I get redirected to the default language translation of the node.

This is very confusing for the end user and they should stay in the same node language after submitting a comment.

Steps to reproduce the issue

This is very easy to replicate on simplytest.me (choose multilingual setup).

If simplytest.me is down (as it currently appears to be), use the following:

  1. $ composer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interaction
  2. install Drupal (for example, use drush si to install Drupal in Italian):
    $ drush si standard \
      --db-url='mysql://root@127.0.0.1/some_dir' \
      --account-name="Kay V" --account-pass=silly.walk.ministry \
      --site-name=Some-Dir \
      --site-mail=noreply@example.com \
      --locale=it
  3. add other languages (e.g. Chinese (simplified), French & English) via UI at admin/config/regional/language
  4. otherwise leave defaults (e.g. skip enabling language switching block; leave Detection and selection method as Url; leave language prefixes unchanged)
  5. add an article in the default language (by default the article content type includes all entity requirements involved in this bug report) /node/add/article
  6. add a comment to the article and hit save
  7. note whether a language prefix appears in the url (no prefix should be there, as this is the default language)
  8. create a new article in another language by entering a different prefix in the url e.g. /en/node/add/article
  9. add a comment to the article and hit save
  10. note again whether a language prefix appears in the url (if the issue exists, the prefix will be missing)
  11. apply patch
  12. drop db tables
  13. repeat from step 2 above

Proposed resolution

Redirect the user to the node translation where the comment is made.

Remaining tasks

#67.4
#79.4
#81

Manual testing

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#113 drupal-3019701-113-submit-comment-multi-lang-redirect.patch4.99 KBwuinfo - Bill Wu
#106 2751269-106.patch4.79 KBSpokje
#106 interdiff_101-106.txt9.1 KBSpokje
#104 2751269--patch-error.png100.33 KBvikashsoni
#101 2751269-101.patch6.28 KBWilfred Waltman
#98 interdiff-2751269-95-98.txt2.02 KBmohit_aghera
#98 2751269-98.patch6.27 KBmohit_aghera
#95 2751269-95.patch5.85 KBKevinVb
#94 2751269-94.patch5.8 KBKevinVb
#88 CleanShot 2020-11-05 at 05.07.51.png53.25 KBamjad1233
#88 interdiff.txt251 bytesamjad1233
#88 2751269-88.patch5.86 KBamjad1233
#87 afterPatch.png43.96 KBRuchi Joshi
#87 beforePatch.png44.29 KBRuchi Joshi
#83 interdiff_80-83.txt1.51 KBraman.b
#83 2751269-83.patch5.86 KBraman.b
#80 interdiff-78-80.txt3.07 KBjungle
#80 2751269-80.patch6.79 KBjungle
#78 interdiff-77-78.txt16.63 KBjungle
#78 2751269-78.patch6.76 KBjungle
#77 interdiff_71_77.txt5.54 KBpavnish
#77 2751269-77.patch22.56 KBpavnish
#71 interdiff-70-71.txt4.34 KBamjad1233
#71 submmiting_comment_redirection_issue-2751269-71.patch23.48 KBamjad1233
#70 interdiff-65-70.txt18.58 KBamjad1233
#70 submmiting_comment_redirection_issue-2751269-70.patch22.31 KBamjad1233
#65 interdiff_58_65.txt1.4 KBpavnish
#65 submmiting_comment_redirection_issue-2751269-65.patch5.32 KBpavnish
#65 test-only_1.patch3.96 KBpavnish
#61 interdiff_58_61.txt1.47 KBpavnish
#61 submmiting_comment_redirection_issue-2751269-61.patch5.32 KBpavnish
#61 test-only_1.patch3.96 KBpavnish
#58 test-only.patch3.96 KBrahul.shinde
#58 submmiting_comment_redirection_issue-2751269-58.patch5.55 KBrahul.shinde
#58 interdiff_49_58.txt4.29 KBrahul.shinde
#53 2751269-53.patch2.27 KBpavnish
#52 interdiff_47_52.txt3.64 KBpavnish
#52 2751269-52.patch5.3 KBpavnish
#41 comment-non-default-lang-add.png152.29 KBatul4drupal
#41 comment-non-default-lang-saved.png160.92 KBatul4drupal
#41 comment-default-lang-add.png153.15 KBatul4drupal
#41 comment-default-lang-saved.png170.04 KBatul4drupal
#34 submmiting_comment_redirection_issue-2751269-32.patch1.58 KBkkalashnikov
#28 submmiting_comment_redirection_issue-2751269-28.patch1.98 KBkkalashnikov
#24 2751269-redirect_to_current_node_language_after_post_comment-24.patch1.57 KBnanak
#23 2751269-redirect_to_current_node_language_after_post_comment-23.patch1.58 KBergonlogic
#20 2751269-redirect_to_current_node_language_after_post_comment-20.patch1.06 KBcosolom
#8 drupal-submitting_comment_redirect-2751269-8-D8.patch689 bytesadriancid
#45 submmiting_comment_redirection_issue-2751269-45.patch6.93 KBrahul.shinde
#45 interdiff_32_45.txt5.15 KBrahul.shinde
#48 test-only.patch4.18 KBrahul.shinde
#48 submmiting_comment_redirection_issue-2751269-47.patch5.76 KBrahul.shinde
#48 interdiff_45_47.txt6.02 KBrahul.shinde

Issue fork drupal-2751269

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yvesvanlaer created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ogggg’s picture

I can confirm this bug.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

adriancid’s picture

Issue summary: View changes

I can confirm this bug too.

Adding the Issue Template to the description.

adriancid’s picture

Version: 8.6.x-dev » 8.5.x-dev
Status: Active » Needs review
FileSize
689 bytes
kay_v’s picture

Issue summary: View changes
kay_v’s picture

Issue summary: View changes
kay_v’s picture

Issue summary: View changes
kay_v’s picture

Status: Needs review » Needs work

I was able to confirm the bug.

I'm marking this issue as 'needs work' with the caveat that the patch may be playing the role it needs to play. Pretty complex matrix of possibilities. Of course it is - it’s multilingual.

Unfortunately (and admittedly with no expert insights into how all the contributing chunks need to link up) I’m not getting the expected results when I save a comment with the patch applied. After the patch, the url to which users are redirected on saving a comment does not contain the language code (uncertain if in fact it should, but I believe it should). The interface has an unexpected mix of languages, perhaps indicating that the patch is working in part. If I enter the language code in the url, I see the unadulterated interface language I anticipate.

My steps to reproduce the issue are in the issue summary; the steps include a lot of detail in case variation is needed to ensure consistency of outcome. It’s certainly worth reviewing my steps in case something there is affecting the context of the patch.

Patch applies cleanly.

Errors appear in Watchdog, esp.

| locale | 04/05/2018 - 22:30 | Created JavaScript translation file for the language… | Kay V |
| page not found | 04/05/2018 - 22:30 | /fr/node/3 | Kay V |
| page not found | 04/05/2018 - 22:30 | /en/node/2 | Kay V |
| locale | 04/05/2018 - 22:30 | Updated JavaScript translation file for the language… | Kay V |
| comment | 04/05/2018 - 22:30 | Comment posted: suppongo che il prossimo…. | Kay V | Visualizza |

Notes on what wouldn't be possible to know from the watchdog lines above:

  • they are pasted just as they appear in the watchdog UI at /en/admin/reports/dblog, meaning that the lowest one happened first in the chronology
  • i.e. comment posted in Italian, the default language, then "page not found" in 2 of the 3 expected languages, but no mention of Chinese, simplified
  • also no instances of "page not found" after subsequent posting of comments in French and English
kay_v’s picture

Issue summary: View changes
alexseif’s picture

I'm also affected by this.
More over, I can't even get the comments to display in the language they were submitted in
https://drupal.stackexchange.com/questions/257610/multilingual-comments-...

adriancid’s picture

@alexseif, there are 2 others patches that you need to apply to get the comments fully functional when you have a multilingual site.

#2751267-16: Comments are not filtered on language
#2958935-9: Comments created in translation are displayed only for admin role

kay_v’s picture

Does this issue (and related issues) possibly merit a higher level of urgency ("major" vs "normal")? It appears, from my brief glimpse at its scope while testing the proposed patch, that the effect on commenters is substantial, and the system affected (the comment system) is a fundamental part of Drupal core. Just floating the notion.

adriancid’s picture

@kay_v yes there are many problems with the comments and the multilingual.

andypost’s picture

All related issues needs work still, in multilingual env looks filtering is best solution in long run

+++ b/core/modules/comment/src/CommentForm.php
@@ -357,7 +357,7 @@ public function preview(array &$form, FormStateInterface $form_state) {
-    $entity = $comment->getCommentedEntity();
+    $entity = $this->entityManager->getTranslationFromContext($comment->getCommentedEntity());

it should be entity repository service, so it needs injection

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

cosolom’s picture

If i don't have content in current language (node opened in fallback language mode), then after submit comment i still redirecting to default node language. To prevent this behavior i used this patch

ergonlogic’s picture

Status: Needs work » Needs review
ergonlogic’s picture

I'm also seeing this behaviour when deleting comments. That is, if I delete a French comment, I'm redirected to the English (default) page.

The patch in #20 works nicely when creating new comments, though.

ergonlogic’s picture

Here's a patch that uses the same approach as #20, to fix redirects following deleting a comment too.

nanak’s picture

Patch ported for 8.7.x., where urlInfo() became toUrl(), preventing #23 from applying.

Status: Needs review » Needs work

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

kkalashnikov’s picture

Assigned: Unassigned » kkalashnikov
kkalashnikov’s picture

kkalashnikov’s picture

Status: Needs work » Needs review
kkalashnikov’s picture

Assigned: kkalashnikov » Unassigned

Status: Needs review » Needs work
kkalashnikov’s picture

Assigned: Unassigned » kkalashnikov
KapilV’s picture

Helping patch #23 it's good to solve the above problem.

@ergonlogic thanks.

kkalashnikov’s picture

Assigned: kkalashnikov » Unassigned
Status: Needs work » Needs review
matsbla’s picture

Status: Needs review » Reviewed & tested by the community

#34 works great!

kkalashnikov’s picture

Assigned: Unassigned » kkalashnikov
atul4drupal’s picture

Executed the patch #34 against Drupal 8.9.x-dev

https://dispatcher.drupalci.org/job/drupal_patches/44839/

atul4drupal’s picture

Status: Needs work » Needs review
Issue tags: +comments, +multilingual

The patch at #34 worked for me on 8.9.x

atul4drupal’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
152.29 KB
160.92 KB
153.15 KB
170.04 KB

patch at #34 worked as expected.
On adding comment in non default language it does not redirects to default language as expected and while adding comment in default language system remains in default language.

Tested on 8.9.x-dev, with English(en) as default language and Hindi(hi) being non-default language.

Moving to RTBC.

kkalashnikov’s picture

Assigned: kkalashnikov » Unassigned

#DrupalIndiaAssociation

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This looks an important fix for multi-lingual sites.

Thanks for filing this bug report and for fixing the issue. Bug fixing is very valuable. In order to commit a bug fix, we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:

  1. https://www.drupal.org/docs/8/testing
  2. https://api.drupal.org/api/drupal/core%21core.api.php/group/testing/8.9.x

I've checked the comment tests and it appears that there is not a test of commenting on a translated entity. Adding a test that does that seems essential to proving we've fixed this issue.

rahul.shinde’s picture

Assigned: Unassigned » rahul.shinde

Creating tests.

rahul.shinde’s picture

Assigned: rahul.shinde » Unassigned
Status: Needs work » Needs review
FileSize
6.93 KB
5.15 KB

Added test for content and its translated counterpart.

andypost’s picture

Issue tags: -Needs tests

Nice! Please file separately test-only.patch to prove it catch regression

alexpott’s picture

Thanks for writing the test @rahul.shinde - it's great to see multilingual comments tested.

  1. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    + * Tests Comment On Multilingual Content/
    

    Could be something like...

    Tests comments on multilingual content.</coode>
    </li>
    
    <li>
    <code>
    +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +  public static $modules = [
    

    protected

  2. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected function setUp() {
    

    For D9 this needs to have void return type hint.

  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +  /**
    +   * Adds additional languages.
    +   */
    +  protected function setupLanguages() {
    +    foreach (['mr', 'fr'] as $langcode) {
    +      ConfigurableLanguage::createFromLangcode($langcode)->save();
    +    }
    +  }
    +
    +  /**
    +   * Creates Article node type with comment field.
    +   */
    +  public function setupBundle() {
    +    // Create a article content type.
    +    $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]);
    +    // Create comment field on article.
    +    $this->addDefaultCommentField('node', 'article');
    +  }
    

    I don't think that adding methods that is only called once from setUp() is needed here. They're not that long and adds the amount you need to think about when reviewing the test.

  4. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +   * Post a comment on given node.
    

    Posts a comment on a given node.

    First line of function docs need to start with a verb that ends in an s... there are some exceptions see https://www.drupal.org/docs/develop/standards/api-documentation-and-comm...

  5. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +    $subject = $this->randomMachineName();
    +    $comment = $this->randomMachineName();
    

    There's not need for these to be machine names. Something like \Drupal\Component\Utility\Random::sentences() is more appropriate.

  6. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +    $patternPrefix = '';
    +    $pathPrefix = '';
    +
    +    // Here we are composing the prefixes for comment form and the pattern to
    +    // match the after post comment.
    +    if (!$language->isDefault()) {
    +      $pathPrefix = $node->language()->getId();
    +      $patternPrefix = $pathPrefix;
    +      $pathPrefix .= '/';
    +      $patternPrefix .= '\/';
    +    }
    ...
    +    $pattern = '/' . $patternPrefix;
    +    $pattern .= 'node\/([0-9]+)#comment-([0-9]+)';
    +    $pattern .= '/';
    +
    +    // Check the url.
    +    preg_match($pattern, $this->getURL(), $match);
    +
    +    $this->assertTrue(isset($match[1]) && isset($match[2]), 'There is issue with posting comment for ' . $language->getName() . '.');
    

    Let's assert the path outside of this method. After calling it. Then we don't need to do all of this work and what the test is testing is easier discern by reading it.

  7. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +    // Determine the visibility of subject form field.
    +    $display_repository = $this->container->get('entity_display.repository');
    +    if ($display_repository->getFormDisplay('comment', 'comment')->getComponent('subject')) {
    +      // Subject input allowed.
    +      $edit['subject[0][value]'] = $subject;
    +    }
    +    else {
    +      $this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.');
    +    }
    

    I don't think this dynamic-ness is necessary. We only exercise one of these code paths in the test.

  8. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +    $this->drupalPostForm(NULL, $edit, t('Save'));
    

    Let's assert a 200 response here.

  9. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,188 @@
    +    $english_node = $this->reloadEntity($english_node);
    ...
    +    $marathi_node = $this->reloadEntity($english_node)->getTranslation('mr');
    ...
    +    $french_node = $this->reloadEntity($english_node)->getTranslation('fr');
    

    Why do we need the reload entity functionality? I'm not sure this is needed.

rahul.shinde’s picture

The last submitted patch, 48: test-only.patch, failed testing. View results

alexpott’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,144 @@
    +    // Add languages.
    +    foreach (['mr', 'fr'] as $lang) {
    +      ConfigurableLanguage::createFromLangcode($lang)->save();
    +    }
    

    After adding the languages we need to call $this->resetAll(); so the container is in multilingual mode.

  2. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,144 @@
    +  protected function postCommentOnMultilingualContent(EntityInterface $node) {
    +
    +    $subject = $this->randomString(4);
    +    $comment = $this->getRandomGenerator()->paragraphs(2);
    +
    +    $language = $node->language();
    +
    +    $path_prefix = '';
    +
    +    // Here, we are composing the prefixes for comment form to post comment.
    +    if (!$language->isDefault()) {
    +      $path_prefix = $node->language()->getId();
    +      $path_prefix .= '/';
    +    }
    +
    +    // Get the comment form.
    +    $this->drupalGet($path_prefix . 'comment/reply/' . $node->getEntityTypeId() . '/' . $node->id() . '/comment');
    

    Here we should pass in $langcode and rewrite this to use the routing system. Less hardcoding of urls and constructing prefixes. So it can be something like

      protected function postCommentOnMultilingualContent(EntityInterface $node, $langcode) {
        $subject = $this->randomString(4);
        $comment = $this->getRandomGenerator()->paragraphs(2);
    
        $options = [
          'language' => ConfigurableLanguage::load($langcode);
        ];
    
        // Get the comment form.
        $url = Url::fromRoute('comment.reply', [
          'entity_type' => $node->getEntityTypeId(),
          'entity' => $node->id(),
          'field_name' => 'comment',
        ], $options);
        $this->drupalGet($url);
    
  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,144 @@
    +    $subject = $this->randomString(4);
    +    $comment = $this->getRandomGenerator()->paragraphs(2);
    ...
    +    $edit['subject[0][value]'] = $subject;
    +    $edit['comment_body[0][value]'] = $comment;
    

    Rather than creating $subject and $comment variables - let's do something like:
    $edit['subject[0][value]'] = $this->randomString();

    Also not not using (4) because the shorter the string the potential more work to do.

  4. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,144 @@
    +    $english_node = Node::create([
    +      'type' => 'article',
    +      'title' => 'Test title',
    +    ]);
    +
    +    $english_node
    +      ->setPublished()
    +      ->save();
    

    Let's call this $node. And then we can do something like...

        // Create multilingual content.
        $node = Node::create([
          'type' => 'article',
          'title' => 'Test title',
        ]);
        $node
          ->addTranslation('mr', ['title' => 'Marathi title'])
          ->addTranslation('fr', ['title' => 'French title'])
          ->save();
    
  5. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,144 @@
    +    $marathi_node = $english_node->addTranslation('mr', ['title' => 'Marathi title']);
    +    $marathi_node
    +      ->setPublished()
    +      ->save();
    +
    +    // Add french translation.
    +    $french_node = $english_node->addTranslation('fr', ['title' => 'French title']);
    +    $french_node
    +      ->setPublished()
    +      ->save();
    

    We don't need to assign $marathi_node or $french_node here. See above...

  6. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,144 @@
    +    // Post a comment on marathi translation.
    +    $marathi_node = $english_node->getTranslation('mr');
    +    $this->postCommentOnMultilingualContent($marathi_node);
    

    We the updated signature this would be something like:

        // Post a comment on marathi translation.
        $this->postCommentOnMultilingualContent($node, 'mr');
        $this->assertSession()->addressEquals('mr/node/1#comment-2');
    

    The $this->assertSession()->addressEquals('mr/node/1#comment-2'); looks really nice now. It's easy to determine what is being tested.

pavnish’s picture

Assigned: Unassigned » pavnish

On it

pavnish’s picture

Assigned: pavnish » Unassigned
Status: Needs work » Needs review
FileSize
5.3 KB
3.64 KB

@alexpott i please review this patch the changes has been done as suggested by you in #50.
RE #50.1:Done
RE #50.2:Done
RE #50.3:Done
RE #50.4:Done
RE #50.5:Done
RE #50.6:Done

pavnish’s picture

Fix lint issue

pavnish’s picture

pavnish’s picture

Assigned: Unassigned » pavnish
Status: Needs review » Needs work

Working on it need to create new patch failed to apply on 8.9

alexpott’s picture

@pavnish thanks for working on this. It's a really good idea if you are submitting a patch that adds a new test (or changes a test) to run the test locally before you upload the patch to drupal.org.

Reviewing #51...

  1. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +  /**
    +   * Modules to install.
    +   *
    +   * @var array
    +   */
    +  protected static $modules = [
    

    Can be {@inheritdoc}

  2. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  protected function setUp(): void {
    

    The :void here makes this only for D9.

  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +  protected function postCommentOnMultilingualContent(EntityInterface $node, $langcode) {
    

    Need to document the $langcode parameter.

  4. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +    $subject = $this->randomString(4);
    +    $comment = $this->getRandomGenerator()->paragraphs(2);
    

    This is not needed.

  5. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +    $options = [
    +      'language' => ConfigurableLanguage::load($langcode);
    +    ];
    

    Unexpected colon.

  6. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +    $edit['subject[0][value]'] = $this->randomString();
    +    $edit['comment_body[0][value]'] = $comment;
    

    We can set the comment without $comment too.

  7. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +    $this->postCommentOnMultilingualContent($node);
    

    Should pass the 'en' langcode too.

alexpott’s picture

  1. +++ b/core/modules/comment/src/CommentForm.php
    @@ -369,9 +369,9 @@ public function preview(array &$form, FormStateInterface $form_state) {
    -    $uri = $entity->toUrl();
    +    $uri = $entity->toUrl('canonical', ['language' => \Drupal::languageManager()->getCurrentLanguage()]);
    

    The test passes without this change. I'm not sure that this is necessary. Or maybe it is but we've not tested it.

  2. +++ b/core/modules/comment/src/Form/DeleteForm.php
    @@ -16,7 +16,7 @@ class DeleteForm extends ContentEntityDeleteForm {
       public function getCancelUrl() {
         // Point to the entity of which this comment is a reply.
    -    return $this->entity->get('entity_id')->entity->toUrl();
    +    return $this->entity->get('entity_id')->entity->toUrl('canonical', ['language' => \Drupal::languageManager()->getCurrentLanguage()]);
       }
    

    We should add test coverage of deleting one of the comments we've added to. And ensure we end up on the correct url.

  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,128 @@
    +    // Get the comment form.
    +    $url = Url::fromRoute('comment.reply', [
    

    Need to add use Drupal\Core\Url; to the use statements.

  4. Also it seems when you comment on a French node the comment only end up on the english node!!!! So right now you're getting redirected back to the correct translated node but you can't see the comment you've just made.
rahul.shinde’s picture

@alexpott, I am uploading following addressing comment #50,

  • interdiff_49_58.txt
  • submmiting_comment_redirection_issue-2751269-58.patch
  • test-only.patch

Thank you @alexpott being patient with reviewing changes and suggestions.

alexpott’s picture

#57 still needs addressing.

  1. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,136 @@
    +  /**
    +   * Modules to install.
    +   *
    +   * @var array
    +   */
    +  protected static $modules = [
    

    {@inheritdoc}

  2. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,136 @@
    +   * @param \Drupal\Core\Entity\EntityInterface $node
    +   *   Node to post comment on.
    +   *
    +   * @param $langcode
    +   *   String language code..
    

    No empty line between the @param's

  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,136 @@
    +    // Post a comment on default language.
    +    $this->postCommentOnMultilingualContent($node, $node->language()->getId());
    ...
    +    $langcode = 'mr';
    +    $marathi_node = $node->getTranslation($langcode);
    +    $this->postCommentOnMultilingualContent($marathi_node, $langcode);
    ...
    +    $langcode = 'fr';
    +    $french_node = $node->getTranslation($langcode);
    +    $this->postCommentOnMultilingualContent($french_node, $langcode);
    

    There's no need to get the translation here. And we can hardcode the langcode passed into postCommentOnMultilingualContent

pavnish’s picture

Assigned: Unassigned » pavnish

Working on #59

pavnish’s picture

@alexpott, I am uploading following addressing comment #59, #57 still need to work looking on test case
RE #59.1:Done
RE #59.2:Done
RE #59.3:Done
interdiff_58_61.txt
submmiting_comment_redirection_issue-2751269-61.patch
test-only.patch
Thank you @alexpott

pavnish’s picture

Assigned: pavnish » Unassigned

The last submitted patch, 58: test-only.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

rahul.shinde’s picture

Status: Needs review » Needs work
+++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
@@ -0,0 +1,129 @@
+    $this->assertSession()->addressEquals('fr/node/1#comment-2');

This will fail as the path is wrong. It should be 'fr/node/1#comment-3'

pavnish’s picture

@rahul.shinde thanks Please review new patch.It's due to the last change was not saved in my system so the patch was failed.
I was checked in my local by phpunit e.i working fine.i think CTRL+Z applied my mistake at the patch creation time.

@alexpott, I am uploading following addressing comment #59, #57 still need to work looking on test case
RE #59.1:Done
RE #59.2:Done
RE #59.3:Done
interdiff_58_65.txt
submmiting_comment_redirection_issue-2751269-65.patch
test-only.patch
Thank you @alexpott

The last submitted patch, 65: test-only_1.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Thanks for working on this, couple of questions/nits

  1. +++ b/core/modules/comment/src/CommentForm.php
    @@ -369,9 +369,9 @@ public function preview(array &$form, FormStateInterface $form_state) {
    -    $uri = $entity->toUrl();
    +    $uri = $entity->toUrl('canonical', ['language' => \Drupal::languageManager()->getCurrentLanguage()]);
    

    Do we need this - I'm not sure we do - looking at the code in ->toUrl it is language aware already.

    see this hunk in Entity::toUrl()

    
    // Display links by default based on the current language.
        // Link relations that do not require an existing entity should not be
        // affected by this entity's language, however.
        if (!in_array($rel, ['collection', 'add-page', 'add-form'], TRUE)) {
          $options += ['language' => $this->language()];
        }
    

    If we do, then we should inject the language manager, as CommentForm already uses container injection.

  2. +++ b/core/modules/comment/src/Form/DeleteForm.php
    @@ -16,7 +16,7 @@ class DeleteForm extends ContentEntityDeleteForm {
    -    return $this->entity->get('entity_id')->entity->toUrl();
    +    return $this->entity->get('entity_id')->entity->toUrl('canonical', ['language' => \Drupal::languageManager()->getCurrentLanguage()]);
    

    Is there a reason we don't use ->getTranslationFromContext here so the two are consistent?

    It would require injecting the entity repository, but this class already has container injection from its parent classes.

    We'd not need the language manager if we used the entity-repository approach.

  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +    // Create a article content type.
    

    ubernit: should be 'an' Article content type (I realise English may be your second language, so apologies for nitpick)

  4. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +   *   String language code..
    

    ubernit: two . here

  5. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +    $this->assertSession()->addressEquals('node/1#comment-1');
    ...
    +    $this->assertSession()->addressEquals('mr/node/1#comment-2');
    ...
    +    $this->assertSession()->addressEquals('fr/node/1#comment-3');
    

    ubernit, we can store $this->assertSession() in a local variable here to avoid creating three instances

larowlan’s picture

Issue tags: +Bug Smash Initiative
alexpott’s picture

The big issue that needs to be resolved here is

Also it seems when you comment on a French node the comment only end up on the english node!!!! So right now you're getting redirected back to the correct translated node but you can't see the comment you've just made.

So while the change makes sense its currently resulting in a much worse user-experience because you're being taken to a page without the comment you've just made!!!!

amjad1233’s picture

Based on the above reviews and running phpcs on various files.

amjad1233’s picture

a few more fixes from the previous patch.

matsbla’s picture

jungle’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/comment/src/CommentForm.php
    @@ -369,9 +369,9 @@ public function preview(array &$form, FormStateInterface $form_state) {
    -    $uri = $entity->toUrl();
    +    $uri = $entity->toUrl('canonical');
    
    +++ b/core/modules/comment/src/Form/DeleteForm.php
    @@ -16,7 +16,7 @@ class DeleteForm extends ContentEntityDeleteForm {
    -    return $this->entity->get('entity_id')->entity->toUrl();
    +    return $this->entity->get('entity_id')->entity->toUrl('canonical');
    

    See \Drupal\Core\Entity\EntityInterface::toUrl()

    public function toUrl($rel = 'canonical', array $options = []);
    

    canonical is the default. So unnecessary changes.

  2. +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
    @@ -63,6 +63,9 @@ abstract class CommentTestBase extends ViewTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
    @@ -20,6 +20,9 @@ class CommentAdminTest extends CommentTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/CommentAnonymousTest.php
    @@ -17,6 +17,9 @@ class CommentAnonymousTest extends CommentTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/CommentBlockTest.php
    @@ -24,6 +24,9 @@ class CommentBlockTest extends CommentTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/CommentBookTest.php
    @@ -29,6 +29,9 @@ class CommentBookTest extends BrowserTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/CommentTranslationUITest.php
    @@ -62,6 +62,9 @@ class CommentTranslationUITest extends ContentTranslationUITestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
    @@ -36,6 +36,9 @@ class CommentFieldFilterTest extends CommentTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/Views/CommentRestExportTest.php
    @@ -35,6 +35,9 @@ class CommentRestExportTest extends CommentTestBase {
    +   * {@inheritDoc}
    
    +++ b/core/modules/comment/tests/src/Functional/Views/CommentTestBase.php
    @@ -56,6 +56,9 @@ abstract class CommentTestBase extends ViewTestBase {
    +   * {@inheritDoc}
    

    {@inheritdoc}, lowercase

  3. +++ b/core/modules/comment/tests/src/Functional/CommentAdminTest.php
    @@ -40,7 +43,7 @@ public function testApprovalAdminInterface() {
    -    // Test that the comments page loads correctly when there are no comments
    +    // Test that the comments page loads correctly when there are no comments.
    

    Tests that ... . start with Tests

  4. +++ b/core/modules/comment/tests/src/Functional/Views/DefaultViewRecentCommentsTest.php
    @@ -65,10 +65,13 @@ class DefaultViewRecentCommentsTest extends ViewTestBase {
    +  /**
    +   *
    +   */
       protected function setUp($import_test_views = TRUE) {
    

    {@inheritdoc} or unexpected change.

  5. +++ b/core/modules/comment/tests/src/Functional/Views/WizardTest.php
    @@ -56,7 +56,6 @@ public function testCommentWizard() {
    -
    

    Or unexpected change, but it's ok.

jungle’s picture

A lot of unexpected changes here, for coding standards violations, we do not have to get all passed, just get which enabled rules/sniffs passed. I would suggest reverting all unexpected changes to coding standard violations. leave them to coding standards relevant issues.

One way to check coding standard violations against ENABLED rules/sniffs

composer run phpcs FILES/DIRS/PATHES/TO/CHECK

Checkout the composer.json for more:

        "phpcs": "phpcs --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --",
pavnish’s picture

Assigned: Unassigned » pavnish

Working On it

pavnish’s picture

Assigned: pavnish » Unassigned
Status: Needs work » Needs review
FileSize
22.56 KB
5.54 KB

@jungle Hi could you please review this patch all the suggestion in #74 has been implemented.
Thanks
Pavnish

jungle’s picture

Version: 8.9.x-dev » 9.1.x-dev
Assigned: Unassigned » jungle
FileSize
6.76 KB
16.63 KB

Thanks, @pavnish!

Reverting all unnecessary coding standard changes. Changing the target version to 9.1.x.

Continue working on it next.

jungle’s picture

  1. See #67.5

    +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +    $this->assertSession()->addressEquals('node/1#comment-1');
    ...
    +    $this->assertSession()->addressEquals('mr/node/1#comment-2');
    ...
    +    $this->assertSession()->addressEquals('fr/node/1#comment-3');
    
    ubernit, we can store $this->assertSession() in a local variable here to avoid creating three instances
  2. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +    $edit['subject[0][value]'] = $this->randomString();;
    

    Two ;

  3. +++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
    @@ -129,9 +129,9 @@ public function testCommentLanguage() {
    +        $this->assertEqual($comment->get('langcode')->value, $langcode, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
    +        $this->assertEqual($comment->get('comment_body')->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
    
    assertEquals()
    
  4. +++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
    @@ -129,9 +129,9 @@ public function testCommentLanguage() {
    -        $this->assertEqual($comment->langcode->value, $langcode, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
    -        $this->assertEqual($comment->comment_body->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
    ...
    +        $this->assertEqual($comment->get('langcode')->value, $langcode, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
    +        $this->assertEqual($comment->get('comment_body')->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
    
    +++ b/core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
    @@ -67,7 +67,7 @@ protected function setUp($import_test_views = TRUE) {
    -    $this->comment->langcode = 'en';
    +    $this->comment->set('langcode', 'en');
    

    Good with this kind of changes. as $this->comment->langcode, $comment->comment_body->value are accessing protected properties. maybe we need a follow up to clear up other occurrences cross the core.

jungle’s picture

+++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
@@ -0,0 +1,131 @@
+  /**
+   * Tests redirection of comment posted on multilingual content.
+   *
+   * Here we tests redirection of the user to the node translation where the
+   * comment is made.
+   *
+   * @throws \Behat\Mink\Exception\ExpectationException
+   */
+  public function testCommentOnMultilingualContent() {

One line is enough here. Especially @throws here makes no sense.

Suggestion:

Tests redirections with posting comments on multilingual content.
quietone’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs manual testing

I read through the issue checking that all the work is complete. I found these are still to do:

#67.4
#79.4
#81

The last manual test was done in #22 on the patch in #20. There has a been a change to CommentForm.php since then so this needs manual testing.

And one question from a brief look at the patch.

  1. +++ b/core/modules/comment/tests/src/Functional/Views/CommentFieldFilterTest.php
    @@ -67,7 +67,7 @@ protected function setUp($import_test_views = TRUE): void {
    -    $this->comment->langcode = 'en';
    +    $this->comment->set('langcode', 'en');
    

    this looks like it is out of scope.

raman.b’s picture

Status: Needs work » Needs review
FileSize
5.86 KB
1.51 KB

Addressing pointers from #82

Status: Needs review » Needs work

The last submitted patch, 83: 2751269-83.patch, failed testing. View results

raman.b’s picture

Status: Needs work » Needs review

Unrelated test failure

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Ruchi Joshi’s picture

FileSize
44.29 KB
43.96 KB

Patch#83 is working as expected-" if I add a comment on a node which is not in the default language, I get redirected to the same translation of the node." Tested it on Drupal 9 version. +1 for RTBC.
Screenshots are attached.

Steps:

1. Visit /admin/modules
2. Install "Language","Configuration Translation","Content Translation"," Interface Translation"
3. Visit /admin/config/regional/language
4. Add "French" language
5. Visit /admin/config/regional/content-language
4. Select Comment and Content from Custom language settings
5. Then Select "TRANSLATABLE" checkbox given against Comment type, Content type- Article and Basic page
6. Mark tick against the checkbox "Show language selector on create and edit pages" Comment type, Content type- Article and Basic page.
7. Save the settings.
8. Create an Article page in default language(English) and then create a french translation for same page.
9. Post comment with French language selection on the french translated page.
10. You will notice the link generated on the posting of comment, url will have "fr" code on it.
11. Now if a comment is posted with Default language(English) selection on french translated page.
12. You will notice the comment link will appear with no code on it.

amjad1233’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
5.86 KB
251 bytes
53.25 KB

Applied the patch and seems to be working as expected. Just added some ubernit stuff as per interdiff. Moving to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

#69 is still not addressed... repeating the comment because it is important.

The big issue that needs to be resolved here is

Also it seems when you comment on a French node the comment only end up on the english node!!!! So right now you're getting redirected back to the correct translated node but you can't see the comment you've just made.

So while the change makes sense its currently resulting in a much worse user-experience because you're being taken to a page without the comment you've just made!!!!

Also there's #72 from @andypost who is a maintainer of the comment module.

cptX’s picture

Can somebody please give a responsible answer to the following question:

If I make a patch to the kernel to address the above issues and build a production website, if in the future the core is corrected and fixes the above will I be able to update the core and remove the patch, or the comments that will have been created with the applied patch will not be compatible with a future corrected core?

I'm building a new multilingual D9 site the last weeks and I selected Drupal over wordpress because I considered Drupal more mature regarding multilingual capabilities, but the moment I realized the problem with the comments all my plan collapsed and now I don't know what to do. The above problems are critical and I don't want to patch the core.

Can we address the redirect issues in a custom module? What do you suggest to do in order to continue building the site on D9 and to not surrender to wordpress?

In the patch I see changes in the following files:
/core/modules/comment/src/CommentForm.php ->patched
/core/modules/comment/tests/src/Functional/CommentLanguageTest.php ->patched
/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php -> new created

Can somebody explain what do I have to do in order to correct the issues in a production site? Do I need to patch only the first file or the other two files are also needed for a functional website? The last 2 files are created just for testing?

UPDATE: I applied the patch only in the first file and it works for submit. Preview of the comment in the translated page doesn't work though. Brings a white page. Delete a comment on a tranlated page redirects to the non-translated page. So 2 out of 3 major issues are not yet solved. By viewing all the above posts I don't understand why we spent so much effort in the testing files and not in the real issues which are the following:
1. Redirect after save (patch looks working)
2. Loading preview (no solution at the moment -> white screen of death)
3. Redirect after delete (no solution at the moment -> still redirects to the non translated page)

We are in post #90 and only the first issue is resolved and this thread is 4 years old!!! I consider the issue major and I really am surprised why this hasn't been solved in the core already! This is basic functionality if you want to have a multilingual site. Am I missing something? How are all the rest working on these issues? Is it because D7 was working fine in all these and D8/D9 changed the architecture and produced new issues?

cptX’s picture

Created a new topic here to raise general awareness for all these issues the comment module has https://www.drupal.org/project/drupal/issues/3196886

andypost’s picture

cptX’s picture

So as it is the usual case with Drupal, an issue takes years to get solved I decided to solve the issues myself in order to proceed with my project. Here are the modifications I did. I'm not a professional Drupal programmer so I'll place here the code without any code standards. A more qualified person should then review my suggestions and provide them in the form of patches. My modifications presented here address the following issues in version 9.1.2 of Drupal:

  1. Comment Save redirect in a translated page
  2. Comment Delete redirect in a translated page
  3. Comment Preview in a translated page

For the first issue (save) in file /core/modules/comment/src/CommentForm.php in function "save"

@line 372 - $entity = $comment->getCommentedEntity();
@line 372 + $entity = $this->entityRepository->getTranslationFromContext($comment->getCommentedEntity());

For the second issue (delete) in file /core/modules/comment/src/Form/DeleteForm.php in function "getCancelUrl"

@line 19 - return $this->entity->get('entity_id')->entity->toUrl();
@line 19 + return $this->entity->get('entity_id')->entity->toUrl('canonical', ['language' => \Drupal::languageManager()->getCurrentLanguage()]);

For the third issue (preview) in file /core/modules/comment/comment.module in function "comment_preview"

@line 496 - $entity = $comment->getCommentedEntity();
@line 496 + $entity = \Drupal::service('entity.repository')->getTranslationFromContext($comment->getCommentedEntity());

Please, let's test the above and produce the corresponding patches, and let's hope it will not take 4.5years more...

KevinVb’s picture

FileSize
5.8 KB

Updated the patch from #83 to make it compatible with Drupal core version 9.1.4

KevinVb’s picture

FileSize
5.85 KB

Well, fixed the file locations in my patch from previous comment.

mohit_aghera’s picture

Status: Needs work » Needs review

Changing to needs review for test bot run.

Status: Needs review » Needs work

The last submitted patch, 95: 2751269-95.patch, failed testing. View results

mohit_aghera’s picture

Status: Needs work » Needs review
FileSize
6.27 KB
2.02 KB
+++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
@@ -0,0 +1,128 @@
+    $assert_session->addressEquals('mr/node/1#comment-2');

It seems tests are silently failing and working fine on local.

As drupal's test bot runs test cases inside a subdirectory, this might be causing issues in similar assertions.

I've updated the patch and using Url::fromRoute to create the URLs.

Let's see how it goes.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andypost’s picture

Wilfred Waltman’s picture

Rerolled #98 for Drupal 9.2.2

Just changed row number and added an 's' twice.

iadiaz’s picture

Great it worked for me in version 8.9.7

Berdir’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/comment/tests/src/Functional/CommentLanguageTest.php
    @@ -146,9 +146,9 @@ public function testCommentLanguage() {
             $comment = Comment::load(reset($cids));
    -        $args = ['%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode];
    -        $this->assertEquals($langcode, $comment->langcode->value, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
    -        $this->assertEquals($comment_values[$node_langcode][$langcode], $comment->comment_body->value, 'Comment body correctly stored.');
    +        $args = ['%node_language' => $node_langcode, '%comment_language' => $comment->get('langcode')->value, '%langcode' => $langcode];
    +        $this->assertEquals($comment->get('langcode')->value, $langcode, new FormattableMarkup('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args));
    +        $this->assertEquals($comment->get('comment_body')->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.');
           }
         }
     
    

    This doesn't seem to make any relevant change?

    Order argument is incorrectly changed on assertEquals() due to the merge ,and the only other chnage is $node->langcode to $node->get('langcode'). I prefer get() too but functionally it is identical.

    Lets try without these changes, I don't see why it wouldn't pass?

  2. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +
    +    // Add languages.
    +    foreach (['mr', 'fr'] as $lang) {
    +      ConfigurableLanguage::createFromLangcode($lang)->save();
    +    }
    

    $lang is an uncommon variable name, we usually use langcode. I would skip the loop and just call createFromLangcode() twice.

  3. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +  /**
    +   * Tests redirections with posting comments on multilingual content.
    +   *
    +   * @throws \Behat\Mink\Exception\ExpectationException
    +   */
    +  public function testCommentOnMultilingualContent() {
    +
    +    // Create multilingual content.
    

    I wouldn't add the @throws on these methods. If you start with that then you'd need to add a lot more from the assertions to be complete. We don't do that on test methods usually.

  4. +++ b/core/modules/comment/tests/src/Functional/CommentOnMultilingualContentTest.php
    @@ -0,0 +1,129 @@
    +    $node
    +      ->addTranslation('mr', ['title' => 'Marathi title'])
    +      ->addTranslation('fr', ['title' => 'French title'])
    +      ->save();
    

    Hm. So what is the expected behavior if you comment with a language that does _not_ have an active translation?

    I would argue that we should actually set the language explicitly even if a translation doesn't exist for it?

    For the test, I would then explicitly _not_ add a fr translation and still test it like that.

vikashsoni’s picture

FileSize
100.33 KB

patch not applied in drupal-9.3.x-dev
Needs to re-roll

bnjmnm’s picture

Removing credit for #104, a screenshot of a patch not applying does not move the issue forward.

The testbot in #101 is able to apply the patch so clearly it's working.

The screenshot does show that the patch you're attempting to apply is not the most recent - it's trying to apply #88 and it's been rerolled since then - the most recent is #101. You should only apply the most recent patch when reviewing, it is not cumulative. The use of bold is because I've mentioned this on several other issues and you may have missed it.

Spokje’s picture

Addressed #103:

1. Changes reverted
2. Done
3. Removed all @throws \Behat\Mink\Exception\ExpectationException
4. I hope I understood this correctly

Spokje’s picture

Status: Needs work » Needs review

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

bigboy’s picture

Had some problems with this issue as well. Don't want to duplicate my comment, so I'll just leave a link here - https://www.drupal.org/project/drupal/issues/2751267#comment-14810709

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Did not read all the comments yet.

But see there are few items in the remaining tasks to be addressed.
Also was tagged for a follow up was that done?

Can re-review later once those are updated

Thanks.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

wuinfo - Bill Wu’s picture

Version: 11.x-dev » 10.2.x-dev
Status: Needs work » Needs review
FileSize
4.99 KB

The patch fixes the issue of the page returning to the default language page after submitting a comment in the non-default language comment form. It did not resolve other problems related to previewing comments and deleting comments. The patch is for Drupal development branch 10.2.x.

needs-review-queue-bot’s picture

Status: Needs review » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

wuinfo - Bill Wu’s picture

Status: Needs work » Needs review
smustgrave’s picture

Version: 10.2.x-dev » 11.x-dev
Status: Needs review » Needs work

Thanks for picking up

MR should be pointed at 11.x branch

Appears to have some remaining tasks that need to be addressed or answered.