Form HTML for the comment form is per user (at least the token + uid on the comment form, plus whatever hook_form_alter() does). This is going to break if render caching is enabled for comments/nodes at the moment.

We might want to postpone this on the comment settings as field patch - that one doesn't fix this issue but it's likely to conflict a lot.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

moshe weitzman’s picture

Issue tags: +D8 cacheability

Unblocked as comments are now a field.

xjm’s picture

Issue tags: +Prague Hard Problems
Wim Leers’s picture

Title: Comment form forces node render caching to be per user » Comment form on same page as comments forces node render caching to be per user

More accurate title.

Wim Leers’s picture

Component: entity system » comment.module
Assigned: Unassigned » Wim Leers
Status: Active » Postponed
FileSize
4.18 KB
amateescu’s picture

+++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php
@@ -150,6 +150,7 @@ public function instanceSettingsForm(array $form, array &$form_state) {
+      '#description' => t('Beware! This makes the page inherently slower for logged in users.'),

What's with all the drama here?

Wim Leers’s picture

Well, 99% of people won't realize the harm that comes with having the comment form on the same page. I figured it might be worthwhile to mention that explicitly.

However, if reviewers don't think that's a good idea, I don't mind removing that :)

Wim Leers’s picture

Issue summary: View changes

Updated issue summary.

Wim Leers’s picture

Wim Leers’s picture

#2118703: Introduce #post_render_cache callback to allow for personalization without breaking the render cache got committed, which means this issue is now unblocked, yay! :)

Reroll to ensure it applies cleanly, and to s/comment_insert_form()/comment_replace_form_placeholder/, which better communicates what the #post_render_cache callback function does.

amateescu’s picture

Don't forget about the "Beware!" stuff. A user facing text like that has no place for being in core :) .. or you might as well change it to "Here be dragons!" or something like that.

Status: Needs review » Needs work

The last submitted patch, 8: comment_form_breaks_render_cache-2099133-8.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: comment_form_breaks_render_cache-2099133-8.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Needs review
Wim Leers’s picture

Issue tags: +Performance, +Spark, +sprint
Wim Leers’s picture

This reroll is identical to the patch in #8, it only removes the "Beware" message amateescu did not like. Could not think of better wording, so it's better to omit it.

(No interdiff because I just removed that hunk from the patch.)

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Code looks great, and the last patch came back green so most recent one should do so as well.

amateescu’s picture

Thanks!

andypost’s picture

+1 to patch, suppose no reason to have tests for this kind of render cache

Wim Leers’s picture

#18: there is *extensive* test coverage in #2118703: Introduce #post_render_cache callback to allow for personalization without breaking the render cache for #post_render_cache. More importantly: existing integration tests don't need to be modified, so we already have test coverage.

msonnabaum’s picture

Yeah, this looks good to me as well.

catch’s picture

Status: Reviewed & tested by the community » Fixed

No complaints here either. Committed/pushed to 8.x, thanks!

Wim Leers’s picture

Issue tags: -sprint
yched’s picture

Could we make comment_replace_form_placeholder() a static method on CommentDefaultFormatter instead ?

Wim Leers’s picture

#23: not yet, because #post_render_cache does not yet support object methods, for the reasons outlined at #2118703-42: Introduce #post_render_cache callback to allow for personalization without breaking the render cache. Rest assured that if it becomes possible, I will happily get rid of comment_replace_form_placeholder().

tstoeckler’s picture

Re #23/#24:

As call_user_func_array() is used to call the callbacks, I would have thought that static class methods are in fact support by #post_render_cache. Because $callback is used as an array key, what is not supported is array($object, 'method') but I don't see a reason statics like 'Drupal\foo\ClassName::staticMethod' shouldn't be supported. I might be wrong, though.

Wim Leers’s picture

Status: Fixed » Needs review
FileSize
2.57 KB

#25: you're absolutely right. This is much better.

Thanks, yched & tstoeckler!

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks! Unless the bot objects this is RTBC.

amateescu’s picture

+++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php
@@ -151,7 +151,7 @@ public function viewElements(FieldItemListInterface $items) {
+              '#callback' => 'Drupal\comment\Plugin\Field\FieldFormatter\CommentDefaultFormatter::renderForm',

Missing the leading '\'.

Wim Leers’s picture

Addresses #29 and improves a comment.

tstoeckler’s picture

We're very inconsistent with this in core currently, so I'm not marking back to "needs work", but on a general note our current coding standard is:

When specifying a class name in a string, use its full name including namespace, without leading \.

(Not advocating that that standard is a good thing, but it's our curent standard.)

amateescu’s picture

Ups, didn't know about that, sorry. But since we're inconsistent anyway, this can be a novice task to fix all over core.

Wim Leers’s picture

Hah, so that's exactly what I was thinking: none of our use Some\Crazy\Namespace\Class statements also omit a leading backslash.

catch’s picture

Status: Reviewed & tested by the community » Fixed

This would've been better in a normal follow-up issue - easier to follow later on. But committed/pushed to 8.x, thanks!

Wim Leers’s picture

Sorry: I wasn't sure what was preferred. Will do so in the future!

xjm’s picture

Issue tags: +beta blocker

Retroactively tagging beta blocker as a blocker for #2151459: Enable node render caching.

Wim Leers’s picture

Retroactively marking critical: a blocker to a critical issue should itself be critical, and this blocked #2151459: Enable node render caching, which is critical.

andypost’s picture

This one already fixed, any reason to mark it?

Status: Fixed » Closed (fixed)

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