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

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


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

commit 4aee974119f4236889d313356961852d9847ec21
Author: Jacques Le Roux <jacques.le.r...@les7arts.com>
AuthorDate: Thu Jun 13 19:01:04 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, though I will backport if it 
makes
    sense there.
---
 .../ofbiz/ecommerce/catalog/AjaxBreadcrumbs.groovy   | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git 
a/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/catalog/AjaxBreadcrumbs.groovy
 
b/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/catalog/AjaxBreadcrumbs.groovy
index cf70b658a..dfde15015 100644
--- 
a/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/catalog/AjaxBreadcrumbs.groovy
+++ 
b/ecommerce/src/main/groovy/org/apache/ofbiz/ecommerce/catalog/AjaxBreadcrumbs.groovy
@@ -18,9 +18,7 @@
 */
 package org.apache.ofbiz.ecommerce.catalog
 
-import org.apache.ofbiz.product.product.ProductContentWrapper
 import org.apache.ofbiz.product.category.*
-import org.apache.ofbiz.base.util.UtilValidate
 
 parentCategoryStr = parameters.parentCategoryStr
 productCategoryId=parameters.category_id
@@ -32,21 +30,23 @@ if(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