From beb3d376b23a02c0256b58d6cd6b3a99d8d85af4 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 6 Jan 2023 12:46:06 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Hypolite Petovan --- src/Core/Config/Util/ConfigFileManager.php | 8 ++++---- src/Core/Config/Util/ConfigFileTransformer.php | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Core/Config/Util/ConfigFileManager.php b/src/Core/Config/Util/ConfigFileManager.php index c7e63a63b..3a4ebb893 100644 --- a/src/Core/Config/Util/ConfigFileManager.php +++ b/src/Core/Config/Util/ConfigFileManager.php @@ -257,13 +257,14 @@ class ConfigFileManager // When reading the config file too fast, we get a wrong filesize, "clearstatcache" prevents that clearstatcache(true, $filename); $content = fread($configStream, filesize($filename)); - // Event truncating the whole content wouldn't automatically rewind the stream, - // so we need to do it manually - rewind($configStream); if (!$content) { throw new ConfigFileException(sprintf('Cannot read file %s', $filename)); } + // Event truncating the whole content wouldn't automatically rewind the stream, + // so we need to do it manually + rewind($configStream); + $dataArray = eval('?>' . $content); // Merge the new content into the existing file based config cache and use it @@ -279,7 +280,6 @@ class ConfigFileManager $data = $configCache->getDataBySource(Cache::SOURCE_DATA); $encodedData = ConfigFileTransformer::encode($data); - if (!$encodedData) { throw new ConfigFileException('config source cannot get encoded'); } diff --git a/src/Core/Config/Util/ConfigFileTransformer.php b/src/Core/Config/Util/ConfigFileTransformer.php index 4eaafe061..ac4990df1 100644 --- a/src/Core/Config/Util/ConfigFileTransformer.php +++ b/src/Core/Config/Util/ConfigFileTransformer.php @@ -34,7 +34,6 @@ class ConfigFileTransformer $categories = array_keys($data); foreach ($categories as $category) { - if (is_null($data[$category])) { $dataString .= "\t'$category' => null," . PHP_EOL; continue;