diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php index f39904988328dcdfd108ab5cc7e8753a5d164724..a16c172537c9eb7c83662b84f2998e1739cc4b27 100644 --- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php +++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php @@ -8,6 +8,8 @@ namespace Magento\Framework\App\ObjectManager\ConfigLoader; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Framework\ObjectManager\ConfigLoaderInterface; +use Magento\Framework\Serialize\SerializerInterface; +use Magento\Framework\Serialize\Serializer\Serialize; class Compiled implements ConfigLoaderInterface { @@ -18,6 +20,11 @@ class Compiled implements ConfigLoaderInterface */ private $configCache = []; + /** + * @var SerializerInterface + */ + private $serializer; + /** * {inheritdoc} */ @@ -26,7 +33,7 @@ class Compiled implements ConfigLoaderInterface if (isset($this->configCache[$area])) { return $this->configCache[$area]; } - $this->configCache[$area] = unserialize(\file_get_contents(self::getFilePath($area))); + $this->configCache[$area] = $this->getSerializer()->unserialize(\file_get_contents(self::getFilePath($area))); return $this->configCache[$area]; } @@ -39,6 +46,20 @@ class Compiled implements ConfigLoaderInterface public static function getFilePath($area) { $diPath = DirectoryList::getDefaultConfig()[DirectoryList::DI][DirectoryList::PATH]; - return BP . '/' . $diPath . '/' . $area . '.json'; + return BP . $diPath . '/' . $area . '.json'; + } + + /** + * Get serializer + * + * @return SerializerInterface + * @deprecated + */ + private function getSerializer() + { + if (null === $this->serializer) { + $this->serializer = new \Magento\Framework\Serialize\Serializer\Serialize(); + } + return $this->serializer; } } diff --git a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php index 33203df3e7249bf03c51abe4f7553f56f2d4e89b..3e2620fc208619f294e2263d47ba8a156436efc4 100644 --- a/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php +++ b/setup/src/Magento/Setup/Module/Di/Compiler/Config/Writer/Filesystem.php @@ -9,6 +9,8 @@ namespace Magento\Setup\Module\Di\Compiler\Config\Writer; use Magento\Framework\App\Filesystem\DirectoryList; use Magento\Setup\Module\Di\Compiler\Config\WriterInterface; +use Magento\Framework\Serialize\SerializerInterface; +use Magento\Framework\Serialize\Serializer\Serialize; class Filesystem implements WriterInterface { @@ -17,6 +19,11 @@ class Filesystem implements WriterInterface */ private $directoryList; + /** + * @var SerializerInterface + */ + private $serializer; + /** * Constructor * @@ -40,7 +47,7 @@ class Filesystem implements WriterInterface file_put_contents( $this->directoryList->getPath(DirectoryList::DI) . '/' . $key . '.json', - serialize($config) + $this->getSerializer()->serialize($config) ); } @@ -55,4 +62,19 @@ class Filesystem implements WriterInterface mkdir($this->directoryList->getPath(DirectoryList::DI)); } } + + /** + * Get serializer + * + * @return SerializerInterface + * @deprecated + */ + private function getSerializer() + { + if (null === $this->serializer) { + $this->serializer = \Magento\Framework\App\ObjectManager::getInstance() + ->get(Serialize::class); + } + return $this->serializer; + } }