View Issue Details

IDProjectCategoryView StatusLast Update
0003777OXID eShop (all versions)4.02. Session handlingpublic2012-04-20 09:55
Reportertjungcl Assigned To 
PriorityurgentSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.5.9 revision 43186 
Fixed in Version4.6.0_RC2 
Summary0003777: minibasket product links change language
Descriptionif you put something to basket in english, then change to german and put something else in the basket, the minibasket-product-links change the session language when clicking.

so, opening the first product via the minibasket-link will always switch seesion-language to english, the second always will change it to german.
TagsNo tags attached.
ThemeBoth
BrowserAll
PHP Versionany
Database Versionany

Activities

tjungcl

2012-04-19 15:45

reporter   ~0006347

Not fixed.
Now changing the language with filled basket crashes the shop in an endless loop (since rev from 6.Apr.)

tjungcl

2012-04-19 15:57

reporter   ~0006348

I hope you can find and fix it soon.

In the meantime, a dirty quickfix that made at least my testshop functional again. Replace the function setLanguageId in class oxbasketitem with:

protected static $_loopdetect = array();
public function setLanguageId( $iLanguageId ){
    if (self::$_loopdetect[$this->getProductId()]) return;
    self::$_loopdetect[$this->getProductId()] = true;

    $iOldLang = $this->_iLanguageId;
    $this->_iLanguageId = $iLanguageId;

    // 0003777: reload content on language change
    if ($iOldLang !== null && $iOldLang != $iLanguageId) {
        $this->_sTitle = null;
        $this->_setArticle($this->getProductId());
    }
    
    self::$_loopdetect[$this->getProductId()] = false;
}

mindaugas.rimgaila

2012-04-19 16:17

reporter   ~0006353

Reminder sent to: tjungcl

Hi,

we can not reproduce locally your described problem.
It works as expected, changing the language minibasket links is changing, shop do not crashes.

Please describe steps, for reproducing shop endless loop.

tjungcl

2012-04-19 16:28

reporter   ~0006355

Thank you for looking into this so fast.

I dont have to do anything special - but we have a customized shop, so it's possible, that this is a side effect with a module.
Here i put something in the basket, go to the checkout (step1) and change language --> server hangs.

however, if you look in the code, the function is quite endangered of looping:

- _validatebasket calls basketitem->setLanguageId (with baselang)
- setLanguageId calls setArticle
- setArticle calls getTitle
- getTitle calls setLanguageId (with baselang)

There are checks (old lang != new lang), but as soon as you have an environment in which the baselanguage is in some way modified by something else, the setLanguageId will start looping as in our case.

You could make it more robust by breaking the loop-possibility completly (for example by not calling setlanguageid in gettitle but setting it directly (not tried that yet).

mindaugas.rimgaila

2012-04-20 09:55

reporter   ~0006365

Removed the possibility of infinity loop in basket item class.

Changes made:

class oxBasketItem >>
  call function "setLanguageId()" only in "init()" function.