View Issue Details

IDProjectCategoryView StatusLast Update
0001746OXID eShop (all versions)4.07. Source code, Testpublic2012-12-10 13:45
Reporteravenger Assigned To 
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version4.2.0 revision 23610 
Fixed in Version4.3.1 revision 27257 
Summary0001746: Overloading "oxbasketitem" with an own module yields error if product is added to basket
DescriptionAfter overloading "oxbasketitem" with an own module the following error message is displayed:

Fatal error: oxBasket::_clearBundles() [<a href='oxbasket.-clearbundles'>oxbasket.-clearbundles</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "pt_basketitem_sellist" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in H:\Apache Group\Apache\htdocs\seifenparadies\oxid_template_switch\oxid\core\oxbasket.php on line 452

Modifying the code in the overloading module directly works fine!

 
Additional InformationThe following module shall overload the "function _setSelectList( $aSelList )" in "oxbasketitem".

class pt_basketitem_sellist extends pt_basketitem_sellist_parent
{
  /**
     * Stores item select lists ( oxbasketitem::aSelList )
     *
     * @param array $aSelList item select lists
     *
     * @return null
     */
  protected function _setSelectList( $aSelList )
  {
    // checking for default select list
    $aSelectLists = $this->getArticle()->getSelectLists();
    if ( !$aSelList || is_array($aSelList) && count($aSelList) == 0 ) {
      if ( $iSelCnt = count( $aSelectLists ) ) {
        $aSelList = array_fill( 0, $iSelCnt, '0' );
      }
    }
    $this->_aSelList = $aSelList;
    if ( count( $this->_aSelList ) && is_array($this->_aSelList) )
    {
      $show_selectlist_artnum=SHOW_SELECTLIST_ARTNUM===true;
      $show_selectlist_stock=SHOW_SELECTLIST_STOCK===true;
      foreach ( $this->_aSelList as $conkey => $iSel )
      {
        $this->_aChosenSelectlist[$conkey] = new Oxstdclass();
        $this->_aChosenSelectlist[$conkey]->name = $aSelectLists[$conkey]['name'];
        $this->_aChosenSelectlist[$conkey]->value = $aSelectLists[$conkey][$iSel]->name;
        if ($show_selectlist_artnum)
        {
          $this->_aChosenSelectlist[$conkey]->artNum = $aSelectLists[$conkey][$iSel]->artNum;
          if ($show_selectlist_stock)
          {
            $this->_aChosenSelectlist[$conkey]->stock = $aSelectLists[$conkey][$iSel]->stock;
          }
        }
      }
    }
  }
}

This produces the a.m. error.

Modifying the code for "function _setSelectList( $aSelList )" directly in "oxbasketitem" works perfectly...
TagsNo tags attached.
Theme
BrowserAll
PHP Versionany
Database Versionany

Relationships

related to 0000316 resolvedarvydas_vapsva oxBasket custom modules are not possible 
related to 0003908 resolvedalfonsas_cirtautas A fatal error message is displayed after user creates a subshop 

Activities

tomas_liubinas

2010-04-06 18:26

reporter   ~0002470

Similar to 0000316

tomas_liubinas

2010-04-09 16:02

reporter   ~0002502

actually I can't reproduce this problem. Happened only once for me. Could you pls confirm that cleaning tmp dir does not help in this case?

tomas_liubinas

2010-04-09 16:09

reporter   ~0002503

also it looks that the behavior of this case depends whether the module is located directly in /modules/ directory or modules/subdir/ directory. I am wondering where is located yours?

avenger

2010-04-10 05:15

reporter   ~0002504

No, clearing "tmp" does not help.

Neither does deleting cookies.

The Module ist stored in a "modules/subdir1/subdir2/" directory.

avenger

2010-04-10 06:26

reporter   ~0002505

I have found a solution for the problem!

In "oxsession.php" replace "public function getBasket()" withe the following code:

    public function getBasket()
    {
      //Avenger -- Ensure existence of "oxbasketitem" class before "unserialize"
      if ( $this->_oBasket === null )
      {
        $sBasket = self::getVar( $this->_getBasketName() );
        if ( $sBasket )
        {
          $oBasketItem=oxnew('oxbasketitem');
          $oBasket = unserialize( $sBasket );
        }
        if (!is_object($oBasket))
        {
          $oBasket = oxNew( 'oxbasket' );
        }
        $this->setBasket( $oBasket );
      }
      //Avenger -- Ensure existence of "oxbasketitem" class before "unserialize"
      return $this->_oBasket;
    }

This makes sure, that the "oxbasketitem" class (and its overloads) are available before baske "unserialize"....

tomas_liubinas

2010-04-12 17:28

reporter   ~0002510

I included oxNew('oxbasketitem') call to the oxSession::getBasket() method. Thanks for the hint.