PHP致命PHP致命错误:在非对象上调用__clone方法

jam*_*Hud 5 php symfony symfony-2.8

所以,我正在做一个项目,我遇到了一个问题,因为我不断收到错误和警告。我对 PHP 很陌生,所以要温柔。该程序使用 PHP 5.5 运行良好但是当我在 PHP 5.6 中运行该程序时,我收到如下几个错误;

[2016 年 10 月 10 日 10:04:46 America/Denver] PHP 警告:在 /hermes/bosnaweb14a/b1234/.../application/vendor/ 中反序列化“MMR\Bundle\CodeTyperBundle\Entity\User”的错误数据格式学说/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 833 [10-Oct-2016 10:04:46 America/Denver] PHP 通知:unserialize():/hermes 中 50 字节偏移量 49 处出错/bosnaweb14a/b1234/.../application/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 833 [10-Oct-2016 10:04:46 America/Denver] PHP 致命错误: __clone 方法在第 837 行的 /hermes/bosnaweb14a/b1234/.../application/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php 中的非对象上调用

项目信息

平台:Symfony PHP 版本:5.6

受影响的代码

public function newInstance()
{
    if ($this->_prototype === null) {
        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)); //Line 833
        }
    }

  return clone $this->_prototype; //Line 837
}
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激

Jus*_*ons 1

我测试过:

var_dump(clone $t=unserialize(sprintf('O:%d:"%s":0:{}', strlen('name'), 'name')));

它有效。

您必须检查其值$this->name是否为空或包含非法字符。

$this->name首先设置在哪里?