Hey there, it is me again.

Short problem description:
We have incorporated the comment count for a node into some teasers. So if a new comment arrives those teasers should be updated.

What I have done:
I have incorporated an option to clear the display cache for certain display modes on comment creation.
So you can now set up for each display mode for each node type if its cache should be cleared if a comment is created for it.

I have decided to make it configurable for EACH display mode, because a big site like ours would not handle a cache clearing of ALL display caches at once that well.
I will try to incorporate both options so people who need it can enable if for a whole node type and others only for certain display modes.

Let me know what you think.
The patch is in the making. Almost done, just need to work around some of the Field Group modules bugs.

func0der

Comments

func0der’s picture

There we go. A perfectly appliable patch ^^

Oh, I have forgotten to mention that the weird behavior you might see on the view mode configuration site is caused by the Field Group module.
I will create a patch and an issue for it today.

func0der’s picture

Status: Active » Needs review
func0der’s picture

Removed a line of code, that should have not been in there in the first place.

func0der’s picture

func0der’s picture

StatusFileSize
new9.21 KB

Okay, after internal testing we have found that clearing the cache on CREATION of a comment is non-sense, because it could not be published at that point.

So I have rewritten the code to clear the cache on publication instead of creation.
This will also work for moderated comments, since the clearing now triggers on publication.
Also it should be cleared on "unpublication" and deletion of a comment. The source has been changed in that way.

A new patch is attached.

func0der

kars-t’s picture

Status: Needs review » Needs work

Maybe shorter function names would be a little easier to understand ;)

display_cache_get_comment_publication_clears_host_entity_cache_settings
display_cache_get_comment_publication_clears_host_entity_cache_setting_name

Maybe just

display_cache_get_comment_publication_settings
display_cache_get_comment_publication_setting_name

And things like this:
variable_get('display_cache_comment_publication_clears_host_entity_cache_' . $node->type, FALSE);

The "name" col in the "variable" table is just a varchar(128). You use 59 Cahrs with this and if there is a very long nodetyp name it might crash..

Well still I would commit this but the problematic part is how to make sure this works? The code seems fine and it should not destroy the modules functionality. Would be great to get more opinions in a different way than just do a release and wait... :)

func0der’s picture

I explicit naming over short names, because you really know that way to which part of the module this piece of code belongs.

I saw the problem with the variable name, too. But I have decided, that no one would name his node type "Supercalifragilisticexpialidocious" and even that is only 35 chars. So I definitely doubt that that will be a problem at any time.

What do you mean by: make sure it works?
What you would want to do to make sure this works is the following: Write tests :P
No, I am just kidding.

What you should do is the following

  1. Create a node type.
  2. Configure the display cache to cache the whole view mode.
  3. Set up the comment clearing for the core view mode "teaser"
  4. include a node in is teaser view mode somewhere on the page. Call that page so the view mode is cached.
  5. Go to the full view mode page of that node where the teaser view mode is NOT! included. Create a comment that is either immediately published or you publish it afterwards yourself.
  6. Check the cache_display_cache table. There should be no entry for the "teaser" view mode for your given node.
kars-t’s picture

Ah I just commit it. Who needs testing...

  • faf5d1d committed on 7.x-1.x
    Issue #2511314 by func0der: [PATCH] Delete a comments host entity...
kars-t’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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