From 339bafc81d7c19cb33d64564483715dff88db969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81mi=20Pelhate?= Date: Sat, 14 Dec 2024 15:31:48 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20serialize=20virtual=20propertie?= =?UTF-8?q?s=20in=20SerializesModels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Illuminate/Queue/SerializesModels.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Illuminate/Queue/SerializesModels.php b/src/Illuminate/Queue/SerializesModels.php index db17b98755af..430dd304e05b 100644 --- a/src/Illuminate/Queue/SerializesModels.php +++ b/src/Illuminate/Queue/SerializesModels.php @@ -32,6 +32,10 @@ public function __serialize() continue; } + if ($this->isVirtualProperty($property)) { + continue; + } + if (! $property->isInitialized($this)) { continue; } @@ -77,6 +81,10 @@ public function __unserialize(array $values) continue; } + if ($this->isVirtualProperty($property)) { + continue; + } + $name = $property->getName(); if ($property->isPrivate()) { @@ -105,4 +113,13 @@ protected function getPropertyValue(ReflectionProperty $property) { return $property->getValue($this); } + + /** + * @param \ReflectionProperty $property + * @return bool + */ + protected function isVirtualProperty(ReflectionProperty $property): bool + { + return method_exists($property, 'isVirtual') && $property->isVirtual(); + } }