wat*_*ver 27 symfony doctrine-orm fosuserbundle
关于我的UserBundle,我又回到了另一个问题:通过Symfony2安装和配置FOS捆绑包时,一切都很完美,它甚至让我创建了2个正确插入我的数据库的用户.
但是,每次我尝试登录这些帐户时,都会出现以下错误
Warning: Erroneous data format for unserializing 'VillaPrivee\UserBundle\Entity\User' in /Users/Vianney/Projets/VillaPrivee/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php line 869
Run Code Online (Sandbox Code Playgroud)
这就是869行所指的:
/**
* Creates a new instance of the mapped class, without invoking the constructor.
*
* @return object
*/
public function newInstance()
{
if ($this->_prototype === null) {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}
return clone $this->_prototype;
}
Run Code Online (Sandbox Code Playgroud)
这是我的用户实体:
namespace VillaPrivee\UserBundle\Entity;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
public function __construct()
{
parent::__construct();
// your own logic
}
}
Run Code Online (Sandbox Code Playgroud)
不知道我做错了什么,因为我只是按照一步一步的文档安装了整件事...感谢各位帮忙
gro*_*row 38
如果您使用的是PHP版本5.4.29或5.5.13
在:"/ vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php "中找到函数"newInstance"(在第827行附近)并按照下面的步骤进行编辑,直到Fix通过doctrine合并为止.
public function newInstance()
{
if ($this->_prototype === null) {
// $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513) {
$this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
} else {
$this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
}
}
return clone $this->_prototype;
}
Run Code Online (Sandbox Code Playgroud)
@Benji:thx的提示:https://github.com/symfony/symfony/issues/11056
wat*_*ver 18
回答我自己的问题,我找到了一个解决方法,感谢这个家伙:
http://www.doctrine-project.org/jira/browse/DDC-3120
在谈到解释时,他比我好得多,但这就是我现在所拥有的,它就像一个魅力!:)
{
if ($this->_prototype === null) {
$this->_prototype = @unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
if ($this->_prototype === false) {
$this->_prototype = @unserialize(sprintf('C:%d:"%s":0:{}', strlen($this->name), $this->name));
}
}
return clone $this->_prototype;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11706 次 |
| 最近记录: |