[MGNLCAT-46] Freemarker error when obtaining category that has no property called "name" Created: 19/Feb/13  Updated: 22/Feb/13  Resolved: 21/Feb/13

Status: Closed
Project: Magnolia Categorization Module
Component/s: None
Affects Version/s: 1.2.5
Fix Version/s: 1.2.5

Type: Bug Priority: Neutral
Reporter: Jaroslav Simak Assignee: Jaroslav Simak
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
relation
is related to MGNLCAT-44 Prevent NPE in CategorizationTemplati... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   
Error on line 15, column 5 in categorization/paragraphs/categoryCloud.ftl
item.name is undefined.
It cannot be assigned to itemName
The problematic instruction:
----------
==> assignment: itemName=item.name [on line 15, column 5 in categorization/paragraphs/categoryCloud.ftl]
 in user-directive assignItemValues [on line 31, column 17 in categorization/paragraphs/categoryCloud.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Error on line 15, column 5 in categorization/paragraphs/categoryCloud.ftl
item.name is undefined.
It cannot be assigned to itemName
	at freemarker.core.Assignment.accept(Assignment.java:111)


 Comments   
Comment by Jan Haderka [ 19/Feb/13 ]
    [#assign itemName = item.name!]
     [#assign itemDisplayName = item.displayName!itemName]
     [#assign itemLevel = item.level]
     [#assign itemLink = model.getCategoryLink(itemName)!]

So you fix this by allowing itemName to be null, but because of that if displayName is not set either, the itemDisplayName later will get the null and created category link will look like ...null...

Generated at Mon Feb 12 04:42:35 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.