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
Update tag for preview cache #153
Conversation
The admin preview function does not work as expected: it always fetches content from the view cache, so the draft content being edited never shows up. To fix this issue, view cache should be purged by triggering listeners attached to `content/cache/translations`. This PR is related to ezsystems/LegacyBridge#153 | Question | Answer | ------------------ | ------------------ | **JIRA issue** | n/a | **Bug** | yes | **New feature** | no | **Target version** | `2017.12` | **BC breaks** | no | **Tests pass** | yes | **Doc needed** | no **TODO**: - [ ] Implement feature / fix a bug. - [ ] Implement tests. - [ ] Fix new code according to Coding Standards (`$ composer fix-cs`). - [x] Ask for Code Review.
Sorry for not giving input sooner, but your PR's made me aware we where lacking a way to invalidate versions properly. So added that here: ezsystems/ezpublish-kernel#2396 It means you can instead just edit exisitng $this->cache->invalidateTags(["content-{$contentId}-version-{$versionNo}"]); Which will now make sure to clear all occurrences of the cache for the specific version, not just the listing of versions. Hope this makes sense to you to, it at least simplifies this a lot ;) EDIT: You can now also drop this from line before |
The admin preview function does not display the draft content that is currently being edited, this is because the preview cache is not purged, and the preview function always fetches content from the view cache, refer to ezsystems/ezpublish-kernel#2396 for details. To fix this issue, `PersistenceCachePurger.php::contentVersion()` has been changed to invalidate cache with the new tags. | Question | Answer | ------------------ | ------------------ | **JIRA issue** | n/a | **Bug** | yes | **New feature** | no | **Target version** | `v2.0.0` | **BC breaks** | no | **Tests pass** | yes | **Doc needed** | no **TODO**: - [ ] Implement feature / fix a bug. - [ ] Implement tests. - [ ] Fix new code according to Coding Standards (`$ composer fix-cs`). - [x] Ask for Code Review.
05a039b
to
879838d
Compare
Hi @andrerom, I have revised the code accordingly. Thanks! |
@@ -168,7 +168,7 @@ public function contentVersion($contentId, $versionNo) | |||
} | |||
|
|||
$this->cache->deleteItem("ez-content-version-info-${contentId}-${versionNo}"); |
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.
you can also drop this one
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.
Ignore that
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.
As we want to make sure this works also for <2.2.2, instead change the lines here to for instance:
// todo Once we can require 2.2.2+, simplify to just invalidate "content-{$contentId}-version-{$versionNo}"
$this->cache->deleteItem("ez-content-version-info-${contentId}-${versionNo}");
$this->cache->invalidateTags(["content-${contentId}-version-list", "content-{$contentId}-version-{$versionNo}"]);
Note that it re-adds content-${contentId}-version-list
, for <2.2.2 releases.
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.
@andrerom So I don't need do anything, do I?
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.
Not anymore at least ;)
The admin preview function does not display the draft content that is
currently being edited, this is because the preview cache is not purged,
and the preview function always fetches content from the view cache,
refer to ezsystems/ezpublish-kernel#2396 for details.
To fix this issue,
PersistenceCachePurger.php::contentVersion()
hasbeen changed to invalidate cache with the new tags.
v2.0.0
TODO:
$ composer fix-cs
).