Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93c276d

Browse files
author
Renaud LITTOLFF
committed
Fix the "Erroneous data format for unserializing" error message
1 parent 5d1275e commit 93c276d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,12 @@ public function __sleep()
908908
public function newInstance()
909909
{
910910
if ($this->_prototype === null) {
911-
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
911+
if (version_compare(PHP_VERSION, '5.4') >= 0) {
912+
$rc = new \ReflectionClass($this->name);
913+
$this->_prototype = $rc->newInstanceWithoutConstructor();
914+
} else {
915+
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
916+
}
912917
}
913918

914919
return clone $this->_prototype;

0 commit comments

Comments
 (0)