99use Magento \Framework \App \Filesystem \DirectoryList ;
1010use Magento \Framework \Config \File \ConfigFilePool ;
1111use Magento \Framework \Exception \FileSystemException ;
12+ use Magento \Framework \Exception \RuntimeException ;
1213use Magento \Framework \Filesystem \DriverPool ;
14+ use Magento \Framework \Phrase ;
1315
1416/**
1517 * Deployment configuration reader.
@@ -87,6 +89,7 @@ public function getFiles()
8789 * @param string $fileKey The file key (deprecated)
8890 * @return array
8991 * @throws FileSystemException If file can not be read
92+ * @throws RuntimeException If file is invalid
9093 * @throws \Exception If file key is not correct
9194 * @see FileReader
9295 */
@@ -99,6 +102,9 @@ public function load($fileKey = null)
99102 $ filePath = $ path . '/ ' . $ this ->configFilePool ->getPath ($ fileKey );
100103 if ($ fileDriver ->isExists ($ filePath )) {
101104 $ result = include $ filePath ;
105+ if (!is_array ($ result )) {
106+ throw new RuntimeException (new Phrase ("Invalid configuration file: '%1' " , [$ filePath ]));
107+ }
102108 }
103109 } else {
104110 $ configFiles = $ this ->configFilePool ->getPaths ();
@@ -108,11 +114,14 @@ public function load($fileKey = null)
108114 $ configFile = $ path . '/ ' . $ this ->configFilePool ->getPath ($ fileKey );
109115 if ($ fileDriver ->isExists ($ configFile )) {
110116 $ fileData = include $ configFile ;
117+ if (!is_array ($ fileData )) {
118+ throw new RuntimeException (new Phrase ("Invalid configuration file: '%1' " , [$ configFile ]));
119+ }
111120 } else {
112121 continue ;
113122 }
114123 $ allFilesData [$ configFile ] = $ fileData ;
115- if (is_array ( $ fileData) && count ( $ fileData ) > 0 ) {
124+ if ($ fileData ) {
116125 $ result = array_replace_recursive ($ result , $ fileData );
117126 }
118127 }
0 commit comments