Skip to content

Commit

Permalink
[6.x] Prevent to serialize uninitialized properties (#33644)
Browse files Browse the repository at this point in the history
* Prevent to serialize uninitialized properties

* Updated test for unitialized properties
  • Loading branch information
Dmytro Kulyk authored Jul 24, 2020
1 parent c4cdfc7 commit 36fdbd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Illuminate/Queue/SerializesModels.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ public function __serialize()
continue;
}

$property->setAccessible(true);

if (! $property->isInitialized($this)) {
continue;
}

$name = $property->getName();

if ($property->isPrivate()) {
Expand Down
2 changes: 2 additions & 0 deletions tests/Integration/Queue/typed-properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class TypedPropertyTestClass

public ModelSerializationTestUser $user;

public ModelSerializationTestUser $unitializedUser;

protected int $id;

private array $names;
Expand Down

0 comments on commit 36fdbd4

Please sign in to comment.