View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0006792 | OXID eShop (all versions) | 4.01. Database handling | public | 2018-02-19 15:53 | 2018-02-23 13:58 |
Reporter | usenff | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | acknowledged | Resolution | open | ||
Product Version | 6.0.1 | ||||
Summary | 0006792: [Enterprise Edition] exception - when adding a newly created model to session | ||||
Description | If you create a model, save it to the database and add the resulting object to the session you get an exception like this: [16-Feb-2018 13:00:53 Europe/Berlin] PHP Fatal error: Uncaught PDOException: You cannot serialize or unserialize PDO instances in /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Core/Session.php:411 Stack trace: #0 [internal function]: PDO->__sleep() #1 /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Core/Session.php(411): session_write_close() #2 /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Application/Controller/OxidStartController.php(71): OxidEsales\EshopCommunity\Core\Session->freeze() #3 /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Core/Config.php(628): OxidEsales\EshopCommunity\Application\Controller\OxidStartController->pageClose() #4 /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Core/ShopControl.php(292): OxidEsales\EshopCommunity\Core\Config->pageClose() #5 /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Core/ShopControl.php(137): OxidEsales\EshopCommunity\Core\ShopControl->_process('OxidEsales\\Esho...', 'addVoucher', NULL, NULL) #6 /var/www/dev.schwab.de/vendo in /var/www/dev.schwab.de/vendor/oxid-esales/oxideshop-ce/source/Core/Session.php on line 411 | ||||
Steps To Reproduce | In one request - create a new VoucherSeries (or any other object that inherits BaseModel) - write it to the database - add it to the session | ||||
Additional Information | The exception is thrown because the BaseModel references a PDO-Object which cant be serialized: The reference is set in: OxidEsales\EshopEnterprise\Core\Model\BaseModel->_insert() Resulting in the following object-chain: \OxidEsales\EshopProfessional\Core\Model\BaseModel :: $_oElement2ShopRelations ==> \OxidEsales\EshopEnterprise\Core\Element2ShopRelations :: $_oDbGateway ==> OxidEsales\EshopEnterprise\Core\Element2ShopRelationsDbGateway :: $_oDb ==> OxidEsales\Eshop\Core\Database\Adapter\Doctrine\Database Possible solution 1: Don't save a reference to the Database in the Element2ShopRelationsDbGateway. Use the Registry instead. Possible solution 2: Implement Element2ShopRelationsDbGateway->__sleep() and set "$_oDb" = NULL | ||||
Tags | No tags attached. | ||||
Attached Files | |||||
Theme | Not defined | ||||
Browser | Not defined | ||||
PHP Version | 7.0 | ||||
Database Version | Not defined | ||||
|
It's true that PDO instances can't be serialized, but I tried to reproduce the described scenario with OXID framework and didn't run into any error. My voucher series object got successfully stored in the session object. So I can't see any problems with OXID eShop. Therefore I have to ask you for a documented script that reproduces the behavior you mentioned here. |
|
Hi, I attached the file "pdoerror.php". If you put it into your source directory and call it via browser it should reproduce the error. Important: The error only occures in the Enterprise Edition. Kind regards, Uwe |
|
Hello Uwe, thank you again for your information and provided data! Unfortunatelly, I have to tell you, that your script looks similar to my own testing script. So as I expected, I didn't run into the error. I added one line to the end of your script to show you the result of my successfull execution (Fig. 1). The issue was tested with a standard installation of OXID eShop Enterprise 6.0.1 running with PHP 7.0. As a conclusion I have to assume that you have done some modifications in the past, now interfering with the given use case. |
|
Hi, I setup an new ee-shop without our changes and ran the "pdoerror.php". The error was logged to my php-error-logs. To see the error in your browser please add the following lines __below__ "require_once $sPath . DIRECTORY_SEPARATOR . "bootstrap.php";" error_reporting(E_ALL); ini_set('display_errors', 1); The output in your browser should be something like this: Fatal error: Uncaught PDOException: You cannot serialize or unserialize PDO instances in [no active file]:0 Stack trace: #0 [internal function]: PDO->__sleep() #1 {main} thrown in [no active file] on line 0 Kind regards, Uwe |
|
Hello Uwe, I modified the script and have to tell, that I now run into the error. Issue is set to acknowledged. Thanks for your response and work. |