View Issue Details

IDProjectCategoryView StatusLast Update
0003395OXID eShop (all versions)1.04. Content, static (register, contact etc.) pagespublic2012-12-07 10:28
ReporterAdrian.Kirchner Assigned To 
Status resolvedResolutionfixed 
Product Version4.5.4 revision 39463 
Fixed in Version4.5.7 revision 41909 
Summary0003395: Race condition in smarty func oxcontent cache mechanism when called with oxloadid param and oxloadid is present in two malls
DescriptionWhen you use the smarty function oxcontent eg. like that:
> [{oxcontent ident="oxstartwelcome"}]
to include the welcome content page in the projects template set, you'll run into a race condition under "heavy load" if those idents are used in two or more malls.
There are two reasons for that:

1) The cache id is built out of the oxloadid (which has no unique constraint in the databse, of course) and the mall id is missing. You can find a patch attached to this report.

2) The way how the template compilation is forced is inappropriate. See the ox_get_timestamp()-function in the core/oxfunctions.php file.
There is a comment "alway compile" followed by this code:
> $iTplTimestamp = time();
I don't know the smarty internals but here we need an appropriate way of compilation forcing.

So this leads to the problem. If the mall with id 1 is requested, each request in the same server second to all other malls is served with the content from mall id 1.
Steps To ReproduceTo reproduce that:

1) Create to content sites with the same oxloadid. Apply different content to that tuples.
2) Include those content snippets to your template by ident and via the oxcontent function
3) Change the following lines in the ox_get_timestamp()-function in the core/oxfunctions.php file:
- $iTplTimestamp = time();
+ $iTplTimestamp = 123;
4) browse to the first mall and make sure that this is the first request after cleaning the tmp-folder
5) browse to the second mall -> you will see the content of mall 1.
Additional InformationAs the content functionality is often used to render informations which are demanded by law (imprint, payment- and shippingconditions), this is a very serious bug.
The attached patch fixes that bug and is diffed against the current public trunk.
Attached Files
function.oxcontent.patch.php (838 bytes)   
--- function.oxcontent.php	2011-11-27 13:31:36.000000000 +0100
+++ function.oxcontent_fix.php	2011-11-27 13:32:41.000000000 +0100
@@ -64,8 +64,8 @@
             $sProp = 'oxcontents__'.$sField;
             $smarty->oxidcache = clone $oContent->$sProp;
             $smarty->compile_check  = true;
-            $sCacheId = oxLang::getInstance()->getBaseLanguage().(int) $myConfig->getShopCurrency();
-            $sText = $smarty->fetch( "ox:".(string)$sIdent.(string)$sOxid.$sField.$sCacheId);
+            $sCacheId = oxLang::getInstance()->getBaseLanguage().(int) $myConfig->getShopCurrency().(int) $myConfig->getShopId();
+            $sText = $smarty->fetch( "ox:".(string)$oContent->getId().(string)$sOxid.$sField.$sCacheId);
             $smarty->compile_check  = $myConfig->getConfigParam( 'blCheckTemplates' );
PHP Versionany
Database Versionany



2012-01-06 14:34

reporter   ~0005591

@developers, I tried to reproduce and got:content not found in the 2nd mall, please check from the source code is this issue exist.

Linas Kukulskis

2012-01-09 10:25

reporter   ~0005593

in cache key generation added shop id.