Affects Version/s: 7.1.X, 7.2.X, Master
Component/s: ~[Archived] WCM
There is an issue with the way we fetch the web content template in JournalArticleLocalServiceImpl.getArticleDisplay(), for an article using a template from Global.
The relevant code is:
Basically what it does, is that it looks for the provided template in the article's site, and if it doesn't find it, it also looks for it in the parent sites and Global, due to getTemplate() being called with the includeAncestorTemplates parameter.
If it still doesn't find it, we take the article's default template (I guess what is DDMTemplateKey on the journalarticle record) and try to fetch that with getTemplate again. But this time a different version of getTemplate() is called, the one without the includeAncestorTemplates parameter, resulting in the template being looked for only in the article's site. Causing this to fail with
if the article is using a template from Global.
This second getTemplate call should also use that includeAncestorTemplates parameter (passed as true here as well): this would be more consistent and failsafe.
Steps that show the problem:
1. Go to the Global site and create a new template for the Basic Web Content structure. Fill its contents with
2. In the guest site, create a new basic web content, making sure it uses the new template. (Actually, the error comes just as well with the built-in BASIC WEB CONTENT template, but I wanted to use a different one because it might be relevant for the test results on 7.1.x)
3. From the database, get the articleId and DDMTemplateKey from the journal article record and replace them in the attached Groovy script, then run it.
Checkpoint: The content is returned according to the template.
4. Try it with an empty templateKey
Checkpoint: It still works fine. (because in this case, it looks for the article's default template already in the first getTemplate() call)
5. Try it with some non-existent templateKey.
Result: The script execution fails with the above-mentioned error. Because it looks for the article's default template with the second getTemplate call)
Expected: It should be able to find the article's default template in the Global site, and print out its content according to that template.