You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mb...@apache.org on 2018/03/13 19:39:33 UTC

svn commit: r1826673 - in /ofbiz/ofbiz-framework/branches/release17.12: ./ applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java

Author: mbrohl
Date: Tue Mar 13 19:39:33 2018
New Revision: 1826673

URL: http://svn.apache.org/viewvc?rev=1826673&view=rev
Log:
Applied fix from trunk for revision: 1826671 
===

Fixed: Wrong locale/fallbackLocale logic in CategoryContentWrapper leads 
to unavailable alternate locale content.
(OFBIZ-10274)

Thanks Martin Becker for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/branches/release17.12/   (props changed)
    ofbiz/ofbiz-framework/branches/release17.12/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java

Propchange: ofbiz/ofbiz-framework/branches/release17.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 13 19:39:33 2018
@@ -10,4 +10,4 @@
 /ofbiz/branches/json-integration-refactoring:1634077-1635900
 /ofbiz/branches/multitenant20100310:921280-927264
 /ofbiz/branches/release13.07:1547657
-/ofbiz/ofbiz-framework/trunk:1819499,1819598,1819800,1819805,1819811,1820038,1820262,1820374-1820375,1820441,1820457,1820644,1820658,1820790,1820823,1820949,1820966,1821012,1821036,1821112,1821115,1821144,1821186,1821219,1821226,1821230,1821386,1821600,1821613,1821628,1821965,1822125,1822310,1822377,1822383,1822393,1822882,1823324,1823467,1823562,1823876,1824260,1824314,1824316,1824732,1824803,1824847,1824855,1825192,1825211,1825216,1825233,1825450,1826374,1826502,1826592
+/ofbiz/ofbiz-framework/trunk:1819499,1819598,1819800,1819805,1819811,1820038,1820262,1820374-1820375,1820441,1820457,1820644,1820658,1820790,1820823,1820949,1820966,1821012,1821036,1821112,1821115,1821144,1821186,1821219,1821226,1821230,1821386,1821600,1821613,1821628,1821965,1822125,1822310,1822377,1822383,1822393,1822882,1823324,1823467,1823562,1823876,1824260,1824314,1824316,1824732,1824803,1824847,1824855,1825192,1825211,1825216,1825233,1825450,1826374,1826502,1826592,1826671

Modified: ofbiz/ofbiz-framework/branches/release17.12/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/branches/release17.12/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java?rev=1826673&r1=1826672&r2=1826673&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/branches/release17.12/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java (original)
+++ ofbiz/ofbiz-framework/branches/release17.12/applications/product/src/main/java/org/apache/ofbiz/product/category/CategoryContentWrapper.java Tue Mar 13 19:39:33 2018
@@ -34,7 +34,6 @@ import org.apache.ofbiz.base.util.Genera
 import org.apache.ofbiz.base.util.StringUtil;
 import org.apache.ofbiz.base.util.UtilCodec;
 import org.apache.ofbiz.base.util.UtilHttp;
-import org.apache.ofbiz.base.util.UtilProperties;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.base.util.cache.UtilCache;
 import org.apache.ofbiz.content.content.ContentWorker;
@@ -143,25 +142,8 @@ public class CategoryContentWrapper impl
             throw new GeneralRuntimeException("Unable to find a delegator to use!");
         }
 
-        List<GenericValue> categoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId).orderBy("-fromDate").cache(cache).queryList();
-        categoryContentList = EntityUtil.filterByDate(categoryContentList);
-
-        GenericValue categoryContent = null;
-        String sessionLocale = (locale != null ? locale.toString() : null);
-        String fallbackLocale = UtilProperties.getFallbackLocale().toString();
-        if ( sessionLocale == null ) sessionLocale = fallbackLocale;
-        // look up all content found for locale
-        for( GenericValue currentContent: categoryContentList ) {
-            GenericValue content = EntityQuery.use(delegator).from("Content").where("contentId", currentContent.getString("contentId")).cache(cache).queryOne();
-            if ( sessionLocale.equals(content.getString("localeString")) ) {
-              // valid locale found
-              categoryContent = currentContent;
-              break;
-            } else if ( fallbackLocale.equals(content.getString("localeString")) ) {
-              // fall back to default locale
-              categoryContent = currentContent;
-            }
-        }
+        List<GenericValue> categoryContentList = EntityQuery.use(delegator).from("ProductCategoryContent").where("productCategoryId", productCategoryId, "prodCatContentTypeId", prodCatContentTypeId).orderBy("-fromDate").cache(cache).filterByDate().queryList();
+        GenericValue categoryContent = EntityUtil.getFirst(categoryContentList);
         if (categoryContent != null) {
             // when rendering the category content, always include the Product Category and ProductCategoryContent records that this comes from
             Map<String, Object> inContext = new HashMap<String, Object>();