9
9
use Magento \Framework \App \Filesystem \DirectoryList ;
10
10
use Magento \Framework \Config \File \ConfigFilePool ;
11
11
use Magento \Framework \Exception \FileSystemException ;
12
+ use Magento \Framework \Exception \RuntimeException ;
12
13
use Magento \Framework \Filesystem \DriverPool ;
14
+ use Magento \Framework \Phrase ;
13
15
14
16
/**
15
17
* Deployment configuration reader.
@@ -87,6 +89,7 @@ public function getFiles()
87
89
* @param string $fileKey The file key (deprecated)
88
90
* @return array
89
91
* @throws FileSystemException If file can not be read
92
+ * @throws RuntimeException If file is invalid
90
93
* @throws \Exception If file key is not correct
91
94
* @see FileReader
92
95
*/
@@ -99,6 +102,9 @@ public function load($fileKey = null)
99
102
$ filePath = $ path . '/ ' . $ this ->configFilePool ->getPath ($ fileKey );
100
103
if ($ fileDriver ->isExists ($ filePath )) {
101
104
$ result = include $ filePath ;
105
+ if (!is_array ($ result )) {
106
+ throw new RuntimeException (new Phrase ("Invalid configuration file: '%1' " , [$ filePath ]));
107
+ }
102
108
}
103
109
} else {
104
110
$ configFiles = $ this ->configFilePool ->getPaths ();
@@ -108,11 +114,14 @@ public function load($fileKey = null)
108
114
$ configFile = $ path . '/ ' . $ this ->configFilePool ->getPath ($ fileKey );
109
115
if ($ fileDriver ->isExists ($ configFile )) {
110
116
$ fileData = include $ configFile ;
117
+ if (!is_array ($ fileData )) {
118
+ throw new RuntimeException (new Phrase ("Invalid configuration file: '%1' " , [$ configFile ]));
119
+ }
111
120
} else {
112
121
continue ;
113
122
}
114
123
$ allFilesData [$ configFile ] = $ fileData ;
115
- if (is_array ( $ fileData) && count ( $ fileData ) > 0 ) {
124
+ if ($ fileData ) {
116
125
$ result = array_replace_recursive ($ result , $ fileData );
117
126
}
118
127
}
0 commit comments