Fixed unserialize Framework\File classes

This commit is contained in:
Matias Griese
2020-12-22 15:10:33 +02:00
parent cf62db1329
commit c333da60d6
3 changed files with 20 additions and 7 deletions

View File

@@ -8,7 +8,7 @@
1. [](#bugfix)
* Fixed port issue with `system.custom_base_url`
* Hide errors with `exif_read_data` in `ImageFile`
* Fixed unserialize in `MarkdownFormatter` class
* Fixed unserialize in `MarkdownFormatter` and `Framework\File` classes
# v1.7.0-rc.20
## 12/15/2020

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Grav\Framework\File;
use Grav\Framework\Compat\Serializable;
use Grav\Framework\File\Interfaces\FileInterface;
use Grav\Framework\Filesystem\Filesystem;
@@ -20,6 +21,8 @@ use Grav\Framework\Filesystem\Filesystem;
*/
class AbstractFile implements FileInterface
{
use Serializable;
/** @var Filesystem */
private $filesystem;
/** @var string */
@@ -67,20 +70,22 @@ class AbstractFile implements FileInterface
}
/**
* @return string
* @return array
*/
public function serialize(): string
final public function __serialize(): array
{
return serialize($this->doSerialize());
return ['filesystem_normalize' => $this->filesystem->getNormalization()] + $this->doSerialize();
}
/**
* @param string $serialized
* @param array $data
* @return void
*/
public function unserialize($serialized): void
final public function __unserialize(array $data): void
{
$this->doUnserialize(unserialize($serialized, ['allowed_classes' => false]));
$this->filesystem = Filesystem::getInstance($data['filesystem_normalize'] ?? null);
$this->doUnserialize($data);
}
/**

View File

@@ -78,6 +78,14 @@ class Filesystem implements FilesystemInterface
return static::getInstance($normalize);
}
/**
* @return bool|null
*/
public function getNormalization(): ?bool
{
return $this->normalize;
}
/**
* Force all paths to be normalized.
*