5
5
*/
6
6
namespace Magento \Framework \View \Model \Layout ;
7
7
8
+ use Magento \Framework \App \ObjectManager ;
8
9
use Magento \Framework \App \State ;
9
10
use Magento \Framework \Config \Dom \ValidationException ;
10
11
use Magento \Framework \Filesystem \DriverPool ;
11
12
use Magento \Framework \Filesystem \File \ReadFactory ;
13
+ use Magento \Framework \Serialize \SerializerInterface ;
12
14
use Magento \Framework \View \Layout \LayoutCacheKeyInterface ;
13
15
use Magento \Framework \View \Model \Layout \Update \Validator ;
14
16
@@ -42,7 +44,7 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface
42
44
/**
43
45
* Cache id suffix for page layout
44
46
*/
45
- const PAGE_LAYOUT_CACHE_SUFFIX = 'page_layout ' ;
47
+ const PAGE_LAYOUT_CACHE_SUFFIX = 'page_layout_merged ' ;
46
48
47
49
/**
48
50
* @var \Magento\Framework\View\Design\ThemeInterface
@@ -54,6 +56,11 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface
54
56
*/
55
57
private $ scope ;
56
58
59
+ /**
60
+ * @var SerializerInterface
61
+ */
62
+ private $ serializer ;
63
+
57
64
/**
58
65
* In-memory cache for loaded layout updates
59
66
*
@@ -173,10 +180,11 @@ class Merge implements \Magento\Framework\View\Layout\ProcessorInterface
173
180
* @param \Magento\Framework\Cache\FrontendInterface $cache
174
181
* @param \Magento\Framework\View\Model\Layout\Update\Validator $validator
175
182
* @param \Psr\Log\LoggerInterface $logger
176
- * @param ReadFactory $readFactory ,
183
+ * @param ReadFactory $readFactory
177
184
* @param \Magento\Framework\View\Design\ThemeInterface $theme Non-injectable theme instance
178
185
* @param string $cacheSuffix
179
186
* @param LayoutCacheKeyInterface $layoutCacheKey
187
+ * @param SerializerInterface|null $serializer
180
188
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
181
189
*/
182
190
public function __construct (
@@ -191,7 +199,8 @@ public function __construct(
191
199
ReadFactory $ readFactory ,
192
200
\Magento \Framework \View \Design \ThemeInterface $ theme = null ,
193
201
$ cacheSuffix = '' ,
194
- LayoutCacheKeyInterface $ layoutCacheKey = null
202
+ LayoutCacheKeyInterface $ layoutCacheKey = null ,
203
+ SerializerInterface $ serializer = null
195
204
) {
196
205
$ this ->theme = $ theme ?: $ design ->getDesignTheme ();
197
206
$ this ->scope = $ scopeResolver ->getScope ();
@@ -205,6 +214,7 @@ public function __construct(
205
214
$ this ->cacheSuffix = $ cacheSuffix ;
206
215
$ this ->layoutCacheKey = $ layoutCacheKey
207
216
?: \Magento \Framework \App \ObjectManager::getInstance ()->get (LayoutCacheKeyInterface::class);
217
+ $ this ->serializer = $ serializer ?: ObjectManager::getInstance ()->get (SerializerInterface::class);
208
218
}
209
219
210
220
/**
@@ -437,12 +447,12 @@ public function load($handles = [])
437
447
438
448
$ this ->addHandle ($ handles );
439
449
440
- $ cacheId = $ this ->getCacheId ();
441
- $ cacheIdPageLayout = $ cacheId . '_ ' . self ::PAGE_LAYOUT_CACHE_SUFFIX ;
450
+ $ cacheId = $ this ->getCacheId () . '_ ' . self ::PAGE_LAYOUT_CACHE_SUFFIX ;
442
451
$ result = $ this ->_loadCache ($ cacheId );
443
- if ($ result ) {
444
- $ this ->addUpdate ($ result );
445
- $ this ->pageLayout = $ this ->_loadCache ($ cacheIdPageLayout );
452
+ if ($ result !== false && $ result !== null ) {
453
+ $ data = $ this ->serializer ->unserialize ($ result );
454
+ $ this ->pageLayout = $ data ["pageLayout " ];
455
+ $ this ->addUpdate ($ data ["layout " ]);
446
456
foreach ($ this ->getHandles () as $ handle ) {
447
457
$ this ->allHandles [$ handle ] = $ this ->handleProcessed ;
448
458
}
@@ -455,8 +465,13 @@ public function load($handles = [])
455
465
456
466
$ layout = $ this ->asString ();
457
467
$ this ->_validateMergedLayout ($ cacheId , $ layout );
458
- $ this ->_saveCache ($ layout , $ cacheId , $ this ->getHandles ());
459
- $ this ->_saveCache ((string )$ this ->pageLayout , $ cacheIdPageLayout , $ this ->getHandles ());
468
+
469
+ $ data = [
470
+ "pageLayout " => (string )$ this ->pageLayout ,
471
+ "layout " => $ layout
472
+ ];
473
+ $ this ->_saveCache ($ this ->serializer ->serialize ($ data ), $ cacheId , $ this ->getHandles ());
474
+
460
475
return $ this ;
461
476
}
462
477
0 commit comments