我真的遇到了一个大问题,因为当我在app.php环境中登录时,我收到了一个警告。就像我使用symfony2一样。
警告:array_merge():参数#1不是数组 C:\ XAMPP \ htdocs中\ Editracker \厂商\ friendsofsymfony \用户束\模型\ user.php的 第181行
这是mu User.php
public function serialize()
{
return serialize(array(
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->expired,
$this->locked,
$this->credentialsExpired,
$this->enabled,
$this->id,
));
}
/**
* Unserializes the user.
*
* @param string $serialized
*/
public function unserialize($serialized)
{
$data1 = unserialize($serialized);
// add a few extra elements in the array to ensure that we have enough keys when unserializing
// older data which does not include all properties.
$data = array_merge($data1, array_fill(0, 2, null));
list(
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->expired,
$this->locked,
$this->credentialsExpired,
$this->enabled,
$this->id
) = $data;
}
你能帮我解决这个吗?
答案 0 :(得分:0)
像这样添加is_array条件:
public function serialize()
{
return serialize(array(
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->expired,
$this->locked,
$this->credentialsExpired,
$this->enabled,
$this->id,
));
}
/**
* Unserializes the user.
*
* @param string $serialized
*/
public function unserialize($serialized)
{
$data1 = unserialize($serialized);
// add a few extra elements in the array to ensure that we have enough keys when unserializing
// older data which does not include all properties.
if (is_array($data1)) {
$data = array_merge($data1, array_fill(0, 2, null));
}
list(
$this->password,
$this->salt,
$this->usernameCanonical,
$this->username,
$this->expired,
$this->locked,
$this->credentialsExpired,
$this->enabled,
$this->id
) = $data;
}