Skip to content

Commit e91a2a7

Browse files
committed
Merge branch 'MDVA-151' into 2.0.5_backlog
2 parents d614317 + 0e375f2 commit e91a2a7

File tree

1 file changed

+17
-10
lines changed
  • app/code/Magento/Widget/Model/ResourceModel/Layout

1 file changed

+17
-10
lines changed

app/code/Magento/Widget/Model/ResourceModel/Layout/Update.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class Update extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
1818
*/
1919
private $_cache;
2020

21+
/**
22+
* @var array
23+
*/
24+
private $layoutUpdateCache;
25+
2126
/**
2227
* @param \Magento\Framework\Model\ResourceModel\Db\Context $context
2328
* @param \Magento\Framework\Cache\FrontendInterface $cache
@@ -55,14 +60,18 @@ public function fetchUpdatesByHandle(
5560
\Magento\Framework\View\Design\ThemeInterface $theme,
5661
\Magento\Framework\App\ScopeInterface $store
5762
) {
58-
$bind = ['layout_update_handle' => $handle, 'theme_id' => $theme->getId(), 'store_id' => $store->getId()];
59-
$result = '';
60-
$connection = $this->getConnection();
61-
if ($connection) {
62-
$select = $this->_getFetchUpdatesByHandleSelect();
63-
$result = join('', $connection->fetchCol($select, $bind));
63+
$bind = ['theme_id' => $theme->getId(), 'store_id' => $store->getId()];
64+
$cacheKey = implode('-', $bind);
65+
if (!isset($this->layoutUpdateCache[$cacheKey])) {
66+
$this->layoutUpdateCache[$cacheKey] = [];
67+
foreach ($this->getConnection()->fetchAll($this->_getFetchUpdatesByHandleSelect(), $bind) as $layout) {
68+
if (!isset($this->layoutUpdateCache[$cacheKey][$layout['handle']])) {
69+
$this->layoutUpdateCache[$cacheKey][$layout['handle']] = '';
70+
}
71+
$this->layoutUpdateCache[$cacheKey][$layout['handle']] .= $layout['xml'];
72+
}
6473
}
65-
return $result;
74+
return isset($this->layoutUpdateCache[$cacheKey][$handle]) ? $this->layoutUpdateCache[$cacheKey][$handle] : '';
6675
}
6776

6877
/**
@@ -79,7 +88,7 @@ protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false)
7988
8089
$select = $this->getConnection()->select()->from(
8190
['layout_update' => $this->getMainTable()],
82-
['xml']
91+
['xml', 'handle']
8392
)->join(
8493
['link' => $this->getTable('layout_link')],
8594
'link.layout_update_id=layout_update.layout_update_id',
@@ -88,8 +97,6 @@ protected function _getFetchUpdatesByHandleSelect($loadAllUpdates = false)
8897
'link.store_id IN (0, :store_id)'
8998
)->where(
9099
'link.theme_id = :theme_id'
91-
)->where(
92-
'layout_update.handle = :layout_update_handle'
93100
)->order(
94101
'layout_update.sort_order ' . \Magento\Framework\DB\Select::SQL_ASC
95102
);

0 commit comments

Comments
 (0)