@@ -132,6 +132,27 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface
132
132
*/
133
133
protected $ cacheSuffix ;
134
134
135
+ /**
136
+ * Status for new added handle
137
+ *
138
+ * @var int
139
+ */
140
+ protected $ handleAdded = 1 ;
141
+
142
+ /**
143
+ * Status for handle being processed
144
+ *
145
+ * @var int
146
+ */
147
+ protected $ handleProcessing = 2 ;
148
+
149
+ /**
150
+ * Status for processed handle
151
+ *
152
+ * @var int
153
+ */
154
+ protected $ handleProcessed = 3 ;
155
+
135
156
/**
136
157
* Init merge model
137
158
*
@@ -217,10 +238,10 @@ public function addHandle($handleName)
217
238
{
218
239
if (is_array ($ handleName )) {
219
240
foreach ($ handleName as $ name ) {
220
- $ this ->_handles [$ name ] = 1 ;
241
+ $ this ->_handles [$ name ] = $ this -> handleAdded ;
221
242
}
222
243
} else {
223
- $ this ->_handles [$ handleName ] = 1 ;
244
+ $ this ->_handles [$ handleName ] = $ this -> handleAdded ;
224
245
}
225
246
return $ this ;
226
247
}
@@ -476,8 +497,17 @@ protected function _loadXmlString($xmlString)
476
497
*/
477
498
protected function _merge ($ handle )
478
499
{
479
- $ this ->_fetchPackageLayoutUpdates ($ handle );
480
- $ this ->_fetchDbLayoutUpdates ($ handle );
500
+ if (!isset ($ this ->_handles [$ handle ]) || $ this ->_handles [$ handle ] == $ this ->handleAdded ) {
501
+ $ this ->_handles [$ handle ] = $ this ->handleProcessing ;
502
+ $ this ->_fetchPackageLayoutUpdates ($ handle );
503
+ $ this ->_fetchDbLayoutUpdates ($ handle );
504
+ $ this ->_handles [$ handle ] = $ this ->handleProcessed ;
505
+ } elseif ($ this ->_handles [$ handle ] == $ this ->handleProcessing
506
+ && $ this ->_appState ->getMode () === \Magento \Framework \App \State::MODE_DEVELOPER
507
+ ) {
508
+ $ this ->_logger ->addStreamLog (\Magento \Framework \Logger::LOGGER_SYSTEM );
509
+ $ this ->_logger ->log ('Cyclic dependency in merged layout for handle: ' . $ handle , \Zend_Log::ERR );
510
+ }
481
511
return $ this ;
482
512
}
483
513
@@ -572,8 +602,6 @@ protected function _fetchRecursiveUpdates($updateXml)
572
602
foreach ($ updateXml ->children () as $ child ) {
573
603
if (strtolower ($ child ->getName ()) == 'update ' && isset ($ child ['handle ' ])) {
574
604
$ this ->_merge ((string )$ child ['handle ' ]);
575
- // Adding merged layout handle to the list of applied handles
576
- $ this ->addHandle ((string )$ child ['handle ' ]);
577
605
}
578
606
}
579
607
if (isset ($ updateXml ['layout ' ])) {
0 commit comments