Skip to content

Commit

Permalink
Fixes #2874 Serializable を実装
Browse files Browse the repository at this point in the history
- Symfony/Cache が Closure を使用している関係で Serializable を実装しないとログインに失敗するため
  • Loading branch information
nanasess authored and chihiro-adachi committed Jun 26, 2020
1 parent a184233 commit 0824c7e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
39 changes: 38 additions & 1 deletion src/Eccube/Entity/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Eccube\Repository\CustomerRepository")
*/
class Customer extends \Eccube\Entity\AbstractEntity implements UserInterface
class Customer extends \Eccube\Entity\AbstractEntity implements UserInterface, \Serializable
{
/**
* @var int
Expand Down Expand Up @@ -1148,5 +1148,42 @@ public function getPoint()
{
return $this->point;
}

/**
* String representation of object
* @link http://php.net/manual/en/serializable.serialize.php
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize()
{
// see https://symfony.com/doc/2.7/security/entity_provider.html#create-your-user-entity
// CustomerRepository::loadUserByUsername() で Status をチェックしているため、ここでは不要
return serialize([
$this->id,
$this->email,
$this->password,
$this->salt,
]);
}

/**
* Constructs the object
* @link http://php.net/manual/en/serializable.unserialize.php
* @param string $serialized <p>
* The string representation of the object.
* </p>
* @return void
* @since 5.1.0
*/
public function unserialize($serialized)
{
list (
$this->id,
$this->email,
$this->password,
$this->salt,
) = unserialize($serialized);
}
}
}
39 changes: 38 additions & 1 deletion src/Eccube/Entity/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity(repositoryClass="Eccube\Repository\MemberRepository")
*/
class Member extends \Eccube\Entity\AbstractEntity implements UserInterface
class Member extends \Eccube\Entity\AbstractEntity implements UserInterface, \Serializable
{
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
Expand Down Expand Up @@ -468,5 +468,42 @@ public function getCreator()
{
return $this->Creator;
}

/**
* String representation of object
* @link http://php.net/manual/en/serializable.serialize.php
* @return string the string representation of the object or null
* @since 5.1.0
*/
public function serialize()
{
// see https://symfony.com/doc/2.7/security/entity_provider.html#create-your-user-entity
// MemberRepository::loadUserByUsername() で Work をチェックしているため、ここでは不要
return serialize([
$this->id,
$this->login_id,
$this->password,
$this->salt,
]);
}

/**
* Constructs the object
* @link http://php.net/manual/en/serializable.unserialize.php
* @param string $serialized <p>
* The string representation of the object.
* </p>
* @return void
* @since 5.1.0
*/
public function unserialize($serialized)
{
list (
$this->id,
$this->login_id,
$this->password,
$this->salt,
) = unserialize($serialized);
}
}
}

0 comments on commit 0824c7e

Please sign in to comment.