1
1
<?php
2
2
/**
3
- * Filesystem configuration loader. Loads configuration from XML files, split by scopes
4
- *
5
3
* Copyright © Magento, Inc. All rights reserved.
6
4
* See COPYING.txt for license details.
7
- *
8
5
*/
9
6
10
7
namespace Magento \Framework \Config \Reader ;
11
8
12
9
/**
10
+ * Filesystem configuration loader. Loads configuration from XML files, split by scopes
11
+ *
13
12
* @SuppressWarnings(PHPMD.NumberOfChildren)
14
13
* @api
15
14
* @since 100.0.2
@@ -140,6 +139,7 @@ public function read($scope = null)
140
139
* @param array $fileList
141
140
* @return array
142
141
* @throws \Magento\Framework\Exception\LocalizedException
142
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
143
143
*/
144
144
protected function _readFiles ($ fileList )
145
145
{
@@ -161,9 +161,27 @@ protected function _readFiles($fileList)
161
161
);
162
162
}
163
163
}
164
+
164
165
if ($ this ->validationState ->isValidationRequired ()) {
165
166
$ errors = [];
166
167
if ($ configMerger && !$ configMerger ->validate ($ this ->_schemaFile , $ errors )) {
168
+ // The merged XML is invalid, but each XML document is individually valid.
169
+ // (If they had errors, we would have thrown an exception in the loop above.)
170
+ // Let's work out which document is causing us a problem.
171
+ $ configMerger = null ;
172
+ foreach ($ fileList as $ key => $ content ) {
173
+ if (!$ configMerger ) {
174
+ $ configMerger = $ this ->_createConfigMerger ($ this ->_domDocumentClass , $ content );
175
+ } else {
176
+ $ configMerger ->merge ($ content );
177
+ }
178
+
179
+ if (!$ configMerger ->validate ($ this ->_schemaFile )) {
180
+ array_unshift ($ errors , "Error in merged XML after reading $ key " );
181
+ break ;
182
+ }
183
+ }
184
+
167
185
$ message = "Invalid Document \n" ;
168
186
throw new \Magento \Framework \Exception \LocalizedException (
169
187
new \Magento \Framework \Phrase ($ message . implode ("\n" , $ errors ))
0 commit comments