New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented tagging responses with comment cache tags #137
Conversation
…nvalidated when editing a comment
02e4f2c
to
5bbc6bc
Compare
@@ -1229,6 +1229,23 @@ protected function getCacheTags($table, array $ids = array(), $parentTable = '', | |||
$tags[] = $ns . $parentTable . '.' . $parentId; | |||
} | |||
|
|||
// Trigger the oncachetags_callback | |||
if (\is_array($GLOBALS['TL_DCA'][$table]['config']['oncachetags_callback'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I like adding a new callback. @contao/developers Is this still how we do it nowadays?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like adding an event here. It's still old fashioned DCA stuff. If we have a new driver, then we might go a different direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm generally fine with the callback principle. The markup also works with our new callback service tags.
However, the callback is strange, because it does not pass the datacontainer object, and (almost?) all other callbacks do that. The callback is also missing some arguments (ptable stuff?) and I would expect to return the tags array (or actually return the tags I want to have merged into the array).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no DC, you don't need one. You also don't need anything else (ptable). I could adjust the return value but it makes no sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you're right, but it's just kinda inconsistent with most other callbacks. I only question if this is clearly backend related? So is it only supposed to set/clear tags on backend operations? Then it totally makes sense in the DCA. But what if we need to clear tags if the member data is edited in the front end?
c75098f
to
420f146
Compare
Modify the methods so they actually do get a |
As discussed in Mumble on November 22nd:
|
Okay, so BC is impossible but tbh I don't think anyone has already overridden one of the methods in their drivers. Maybe I should make them |
The easiest solution would probably be to execute if (System::getContainer()->has('fos_http_cache.cache_manager'))
{
$cacheManager = System::getContainer()->get('fos_http_cache.cache_manager');
$cacheManager->invalidateTags($this->getCacheTags($this->strTable, $ids));
} in the |
|
Bummer. Then I guess we have to create a data container object. Or maybe we were wrong about the changes in the first place? |
cb069f4
to
10ba742
Compare
As discussed in Mumble: Generate a DC for every ID that's going to be deleted and pass this to the invalidation method before the record is actually deleted. |
Done, ready to review 😄 |
After this PR has been merged, we should also fix existing |
{ | ||
if (!System::getContainer()->has('fos_http_cache.cache_manager')) | ||
{ | ||
return; | ||
} | ||
|
||
// Filter empty tags | ||
$tags = array_filter(array_unique($tags)); | ||
$tags = $this->getCacheTags($dc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this method is no longer used anywhere else, we might as well remove it and execute the logic here. Then it would also become more obvious how the callback should be named: oninvalidate_cache_tags_callback
(similar to onrestore_version_callback
)
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice input! You're right, changed right away: f183f3a
One last thing regarding this change: case 'id':
$this->intId = $varValue;
break; Could there be someone out there who relied on |
I think it was not. Would be very strange to have different id's there. |
Thank you @Toflar. |
Implementation for #135