Apply suggestions from code review

Co-authored-by: Hypolite Petovan <hypolite@mrpetovan.com>
This commit is contained in:
Philipp 2023-01-06 12:46:06 +01:00 committed by GitHub
parent 05048d4abf
commit beb3d376b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -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');
}

View file

@ -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;