This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git


The following commit(s) were added to refs/heads/release18.12 by this push:
     new 5d8c7f3f2 Fixed: Bug in AjaxBreadcrumbs.groovy (OFBIZ-13118)
5d8c7f3f2 is described below

commit 5d8c7f3f239900b26f8aa37acfef6841259ee98a
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Thu Jun 13 19:04:01 2024 +0200

    Fixed: Bug in AjaxBreadcrumbs.groovy (OFBIZ-13118)
    
    I found this bug in trunk demo error.log
    
    2024-06-12 09:30:20,219 |-0.0.0.0-8009-exec-8 |ControlServlet               
 |E| Error in request handler:
    java.lang.IllegalArgumentException: Error running script at location
    [component://ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy]: 
java.lang.NullPointerException
        at 
org.apache.ofbiz.base.util.ScriptUtil.executeScript(ScriptUtil.java:348) 
~[ofbiz.jar:?]
        at 
org.apache.ofbiz.base.util.ScriptUtil.executeScript(ScriptUtil.java:324) 
~[ofbiz.jar:?]
    [...]
        at AjaxBreadcrumbs.run(AjaxBreadcrumbs.groovy:48) ~[?:?]
        at 
org.apache.ofbiz.base.util.GroovyUtil.runScriptAtLocation(GroovyUtil.java:209) 
~[ofbiz.jar:?]
        at 
org.apache.ofbiz.base.util.ScriptUtil.executeScript(ScriptUtil.java:342) 
~[ofbiz.jar:?]
        ... 61 more
    2024-06-12 09:30:20,223 |-0.0.0.0-8009-exec-8 |ControlServlet
                    |E| An error occurred, going to the errorPage: 
/error/error.jsp
    
    I don't know how to reproduce locally and I did not check error.log in 18.12
    (stable) demo. So I consider it a minor bug, and backport it as it makes
    sense there.
---
 ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy 
b/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy
index 60c69eb0a..1d1eff6b4 100644
--- a/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy
+++ b/ecommerce/groovyScripts/catalog/AjaxBreadcrumbs.groovy
@@ -30,21 +30,23 @@ if(!UtilValidate.isEmpty(parentCategoryStr)) {
         cateMap = [:]
         category = from("ProductCategory").where("productCategoryId", 
path).queryOne()
         categoryContentWrapper = new CategoryContentWrapper(category, request)
-        
+
         pathTemp = pathTemp + path
         cateMap.title = categoryContentWrapper.get("DESCRIPTION", "html")
         cateMap.productCategoryId = category.productCategoryId
         cateMap.parentCategory = pathTemp
-        
+
         cateList.add(cateMap)
-        
+
         pathTemp = pathTemp + '/'
     }
 
     context.productCategoryTrail = cateList
 }
-currentCategory = from("ProductCategory").where("productCategoryId", 
productCategoryId).queryOne()
-currentCategoryContentWrapper = new CategoryContentWrapper(currentCategory, 
request)
-context.currentCategoryName = 
currentCategoryContentWrapper.get("CATEGORY_NAME", "html")
-context.currentCategoryDescription = 
currentCategoryContentWrapper.get("DESCRIPTION", "html")
-context.currentCategoryId = productCategoryId
+if (productCategoryId) {
+    currentCategory = from("ProductCategory").where("productCategoryId", 
productCategoryId).queryOne()
+    currentCategoryContentWrapper = new 
CategoryContentWrapper(currentCategory, request)
+    context.currentCategoryName = 
currentCategoryContentWrapper.get("CATEGORY_NAME", "html")
+    context.currentCategoryDescription = 
currentCategoryContentWrapper.get("DESCRIPTION", "html")
+    context.currentCategoryId = productCategoryId
+}

Reply via email to