Skip to content

Commit 22c2cee

Browse files
authored
Prevent serializing default values (#41348)
1 parent 52b2b26 commit 22c2cee

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Illuminate/Queue/SerializesModels.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ public function __serialize()
7171
continue;
7272
}
7373

74+
$value = $this->getPropertyValue($property);
75+
76+
if ($property->hasDefaultValue() && $value === $property->getDefaultValue()) {
77+
continue;
78+
}
79+
7480
$name = $property->getName();
7581

7682
if ($property->isPrivate()) {
@@ -79,9 +85,7 @@ public function __serialize()
7985
$name = "\0*\0{$name}";
8086
}
8187

82-
$values[$name] = $this->getSerializedPropertyValue(
83-
$this->getPropertyValue($property)
84-
);
88+
$values[$name] = $this->getSerializedPropertyValue($value);
8589
}
8690

8791
return $values;

0 commit comments

Comments
 (0)