View Issue Details

IDProjectCategoryView StatusLast Update
0006792OXID eShop (all versions)4.01. Database handlingpublic2018-02-23 13:58
Status acknowledgedResolutionopen 
Product Version6.0.1 
Target VersionFixed in Version 
Summary0006792: [Enterprise Edition] exception - when adding a newly created model to session
DescriptionIf 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/
Stack trace:
#0 [internal function]: PDO->__sleep()
#1 /var/www/ session_write_close()
#2 /var/www/ OxidEsales\EshopCommunity\Core\Session->freeze()
#3 /var/www/ OxidEsales\EshopCommunity\Application\Controller\OxidStartController->pageClose()
#4 /var/www/ OxidEsales\EshopCommunity\Core\Config->pageClose()
#5 /var/www/ OxidEsales\EshopCommunity\Core\ShopControl->_process('OxidEsales\\Esho...', 'addVoucher', NULL, NULL)
#6 /var/www/ in /var/www/ on line 411
Steps To ReproduceIn one request
- create a new VoucherSeries (or any other object that inherits BaseModel)
- write it to the database
- add it to the session
Additional InformationThe exception is thrown because the BaseModel references a PDO-Object which cant be serialized:

The reference is set in:

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
TagsNo tags attached.
ThemeNot defined
BrowserNot defined
PHP Version7.0
MySQL VersionNot defined



2018-02-20 12:45

administrator   ~0012389

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.


2018-02-20 13:30

reporter   ~0012390


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,

pdoerror.php (1,335 bytes)


2018-02-20 15:51

administrator   ~0012391

Last edited: 2018-02-20 15:51

View 2 revisions

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.

pdoErrorNotReproducable.JPG (349,336 bytes)


2018-02-20 16:27

reporter   ~0012392


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";"

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,


2018-02-23 13:58

administrator   ~0012394

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.