[Pages] Removing contents from containers does not refresh cache
Expected Behavior
After a content is removed from a container, Behavior of pages on Edit/Preview/Mode should reflect this latest update and never show the content that was recently removed.
Current Behavior
If we remove a content from a container, the recently removed content is still displayed in the same page on Live Mode. Edit/Preview mode shows the right behavior. Even if we set the page Cache TTL to zero, or if we set ?dotcache=no/refresh on the URI, the page is not refreshed.
Possible Solution
Update/Invalidate the live-version cached objects for this page and associated contents.
Known Workarounds
Flush all caches.
Steps to Reproduce (for bugs)
- Create a test page, using any template. Save/Publish it.
- Add a live content to any of its containers.
- Check the page on Live/Preview/Edit mode. Content is added to the container. Add the page on a different browser and check that the content is displayed there as well.
- On Edit Mode, remove the content you added from the container.
- Switch to Preview and Live Mode.
- Preview mode doesn't show the content that was removed.
- Live mode does.
- Check the same page on a different browser, without logging in to the backend. Content still shows up on the page.
Context
Reported on latest master and on dotCMS 4.1.1, according to customer's instructions here https://dotcms.zendesk.com/agent/tickets/90583
Screencast: https://drive.google.com/file/d/0B48uh-u7fegRRVZ5T3BSb0VZMHM/view?usp=sharing
Your Environment
- dotCMS version used: current master, 4.1.1.
- Browser Name and version: Any OS.
- Operating System and version: Any OS.
- Application Server and version: Tomcat 8.0.18
- Java Brand and version: Java 8u121.
- Database and version: Postgres, H2.
- Application module (if apply): N/A
Issue happens also if a content was recently removed and then it's added back to the same container.
Typo on branch name and committed message. Fix is here https://github.com/dotCMS/core/commit/3387de6bd3ccd7510413a5aeff966ec8f38c92cb
PR for Master: https://github.com/dotCMS/core/pull/12720
PR for Release-4.2: https://github.com/dotCMS/core/pull/12721
@joseorsini I'm assuming there was a real issue here, but note that in your original steps to reproduce the behavior looks like it's correct - since you didn't save/publish the page between steps 4 and 5, the content should no longer show in the preview mode (which shows you what the page will look like if you publish the page), but should still show in the live mode (since you haven't published the changes you made yet). The content you remove shouldn't disappear from the Live version of the page until you save/publish the page.
@john-thomas-dotcms I believe an update in the MultiTree relationships here wouldn't require the user to manually publish a page here. We would expect that the MultiTree relationship (which is not versionable) is refreshed on cache, because once a content is added/removed from a container, the relationships are already updated in the DB side of things. It was just a matter of invalidating cache here, and user does not have to go and publish the page manually, reducing the amount of steps to do in order to see an updated version of the page they're editing.
@joseorsini if they don't have to publish the page for the changes to go live, then: A. What is the point of having the publish option for the page? B. What is the point of having Preview vs. Live modes on the page?
I think that it's intuitive and maybe necessary that adding a content to a page in the page editor does not automatically publish the changes. Part of the goal of the Preview mode is to allow users to see what their changes will look like if they do publish it.
And what happens if the user adding the content to the page has edit permissions for the page but not publish permissions for it? Maybe I'm not understanding something here, , but it seems wrong on a few different levels to publish the changes immediately (without the user explicitly taking the publish action).
This fix is broken some unit test...
P.R https://github.com/dotCMS/core/pull/12946
These changes broke a jenkins test:
https://cb.dotcms.com/view/builds%20-%20full%20-%20master/job/Build_Full_Tester_Func_Int_master_Postgres/lastCompletedBuild/testReport/com.dotmarketing.portlets.contentlet.business/ContentletAPITest/getContentletReferences/
java.lang.NullPointerException
at com.dotmarketing.factories.MultiTreeFactory.updateVersionTs(MultiTreeFactory.java:691)
at com.dotmarketing.factories.MultiTreeFactory.deleteMultiTree(MultiTreeFactory.java:204)
at com.dotmarketing.factories.MultiTreeFactory.deleteMultiTree(MultiTreeFactory.java:185)
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.destroyContentlets(ESContentletAPIImpl.java:1544)
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.deleteContentlets(ESContentletAPIImpl.java:1717)
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.delete_aroundBody42(ESContentletAPIImpl.java:1427)
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl$AjcClosure43.run(ESContentletAPIImpl.java:1)
at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149)
at com.dotcms.aspects.aspectj.AspectJDelegateMethodInvocation.proceed(AspectJDelegateMethodInvocation.java:43)
at com.dotmarketing.db.LocalTransaction.wrapReturnWithListeners(LocalTransaction.java:39)
at com.dotcms.aspects.interceptors.WrapInTransactionMethodInterceptor.invoke(WrapInTransactionMethodInterceptor.java:23)
at com.dotcms.aspects.aspectj.WrapInTransactionAspect.invoke(WrapInTransactionAspect.java:41)
A question: this NPE is triggered by the time contents are being destroyed, however, the MultiTreeFactory.deleteMultiTree call is done by the time:
- Contents are archived.
- Contents still have a valid version info.
Since Language and Id are values that are persisting in contents, and content is not fully deleted yet, why it returns a null VersionInfo for these contents?
New issues surfaced during tests, in order to reproduce issues reported by regression tests. Reported under
https://github.com/dotCMS/core/issues/12999
Fixed, tested in the last master // postgres // FF
Passed QA. Upgrade from dotcms_3.6 to master branch Ubuntu 14.04.1 / Postgres 9.6 / Chrome v54.0.2840.98 / Tomcat 8 / Java 8