Skip to content

Commit 04c1e4c

Browse files
committed
Add JSON_PRESERVE_ZERO_FRACTION to the json_encode of the system state. This ensures that floats like 10.0 are encoded as floats and decodes as such (instead of being encoded as 10 and decoded as int)
1 parent 1786860 commit 04c1e4c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Scheduler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public function saveStateAsync(FilesystemInterface $filesystem)
546546
return;
547547
}
548548
$file = $filesystem->file($filename);
549-
$file->putContents(json_encode($this->buildState(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))->then(function () use ($file) {
549+
$file->putContents(json_encode($this->buildState(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION))->then(function () use ($file) {
550550
$file->rename($this->saveFileName)->then(function (\React\Filesystem\Node\FileInterface $newfile) {
551551
//Everything Good
552552
$this->asyncSaveInProgress = false;
@@ -571,7 +571,7 @@ public function saveStateSync()
571571
$this->logger->critical("Error creating temporary save state file, check filesystem");
572572
return;
573573
}
574-
$state = json_encode($this->buildState(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
574+
$state = json_encode($this->buildState(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRESERVE_ZERO_FRACTION);
575575
if (!(@file_put_contents($filename, $state) === strlen($state) && rename($filename, $this->saveFileName))) {
576576
$this->logger->critical("Save state sync failed. {lasterror}", ['lasterror' => json_encode(error_get_last())]);
577577
return;

0 commit comments

Comments
 (0)