View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001746 | OXID eShop (all versions) | 4.07. Source code, Test | public | 2010-04-03 10:38 | 2012-12-10 13:45 |
Reporter | avenger | Assigned To | |||
Priority | normal | Severity | block | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 4.2.0 revision 23610 | ||||
Fixed in Version | 4.3.1 revision 27257 | ||||
Summary | 0001746: Overloading "oxbasketitem" with an own module yields error if product is added to basket | ||||
Description | After 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 Information | The 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... | ||||
Tags | No tags attached. | ||||
Theme | |||||
Browser | All | ||||
PHP Version | any | ||||
Database Version | any | ||||
related to | 0000316 | resolved | arvydas_vapsva | oxBasket custom modules are not possible |
related to | 0003908 | resolved | alfonsas_cirtautas | A fatal error message is displayed after user creates a subshop |
|
Similar to 0000316 |
|
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? |
|
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? |
|
No, clearing "tmp" does not help. Neither does deleting cookies. The Module ist stored in a "modules/subdir1/subdir2/" directory. |
|
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".... |
|
I included oxNew('oxbasketitem') call to the oxSession::getBasket() method. Thanks for the hint. |