Problem/Motivation

In a multilingual site, if you are adding a comment on a node that is in the default language, the preview functionality works as expected.
Whereas, on the translated node the comment preview functionality results in an error as it tries to render the comment field in an infinite loop.

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):
  3.   $ 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 \
  4. add other languages (e.g., Marathi and French) via UI at admin/config/regional/language
  5. otherwise leave defaults (e.g., skip enabling language switching block; leave Detection and selection method as Url; leave language prefixes unchanged)
  6. 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
  7. after that add translation to the content
  8. Navigate to the article with the default language. e.g. url /node/
  9. add a comment to the article and hit preview
  10. it will show the comment preview + form + content
  11. save the comment.
  12. now navigate to the translated article page, for french the url will be /fr/node/
  13. add a comment to the article and hit preview
  14. it will lead to WSOD, or some error log

Proposed resolution

Set the status of the comment field on the entity to hidden after the preview is built.

Remaining tasks

Patch.

User interface changes

None.

API changes

Not sure.

Data model changes

None.

Original report by rahul.shinde

In a multilingual site, if you are adding a comment on a node that is in the default language, the preview functionality works as expected.
Whereas, on the translated node the comment preview functionality throws the following message when Xdebug is on,
"The website encountered an unexpected error. Please try again later." with watchdog entry

Error: Maximum function nesting level of '512' reached, aborting! in Drupal::service() (line 157 of /app/core/lib/Drupal.php) 
......

otherwise, find the following error in the PHP error log,
"PHP Fatal error: Maximum execution time of 30 seconds exceeded in ../vendor/symfony/http-foundation/Request.php on line 2108"

CommentFileSizeAuthor
#23 3145146-nr-bot.txt1.05 KBneeds-review-queue-bot

Issue fork drupal-3145146

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:

Comments

rahul.shinde created an issue. See original summary.

cptX’s picture

This issue is already discussed here https://www.drupal.org/project/drupal/issues/2751269

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

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
larowlan’s picture

Priority: Normal » Major
Issue tags: -comments, -multilingual +Bug Smash Initiative

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

Version: 9.5.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sukr_s made their first commit to this issue’s fork.

sukr_s’s picture

Issue summary: View changes
Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

No one has chimed in so maybe it is okay.

1) Drupal\Tests\comment\Functional\CommentPreviewTest::testCommentPreviewOnTranslatedNode
Behat\Mink\Exception\ResponseTextException: The text "Preview comment" was not found anywhere in the text of the current page.
/builds/issue/drupal-3145146/vendor/behat/mink/src/WebAssert.php:907
/builds/issue/drupal-3145146/vendor/behat/mink/src/WebAssert.php:293
/builds/issue/drupal-3145146/core/tests/Drupal/Tests/WebAssert.php:975
/builds/issue/drupal-3145146/core/modules/comment/tests/src/Functional/CommentPreviewTest.php:287
/builds/issue/drupal-3145146/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
ERRORS!
Tests: 4, Assertions: 118, Errors: 1.

Test coverage is there and the fix does solve the issue.

Going to mark.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs title update

I read the IS, comments and the MR. There is an unanswered query in the MR. I will set this to needs work for that.

The test should be changed to use the API for setup tasks. See #3305376: [Meta] Perform set-up tasks in Browser tests using API calls rather than browser requests for examples.

Also, needs a title update.

sukr_s’s picture

Status: Needs work » Needs review

- Queries answered
- Tests changed to use API instead of browser call for setting up data.

smustgrave’s picture

Should move to NW for title update but left a comment on MR that's up for discussion.

smustgrave’s picture

Status: Needs review » Needs work

Left a comment but am moving to NW for the title update mentioned in #14

sukr_s’s picture

@smustgrave could you help with the title update please. I'm not sure what it needs to change to as the current title explains the problem aptly.

sukr_s’s picture

Issue summary: View changes
Status: Needs work » Needs review

Taken a shot at updating IS.

smustgrave’s picture

Issue tags: -Needs title update

Title seems fine to me.

yevko’s picture

I was able to reproduce the issue with 11.0.1 and MR fixed it!

yevko’s picture

Issue tags: +Barcelona2024
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.05 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

needs-review-queue-bot’s picture

Status: Needs work » Needs review

False positive

larowlan’s picture

Status: Needs review » Needs work
Issue tags: +Singapore2024

Thanks for working on this, left a suggestion

immaculatexavier made their first commit to this issue’s fork.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.